loading

BS4 Alerts

Bootstrap 4 Alerts

An easy way to construct predefined alert messages is offered by Bootstrap 4:

==== LIVE ANIMATION MUKAVU ====

The .alert class is used to produce alerts, which are then followed by one of the contextual classes (.alert-primary, .alert-secondary, .alert-light, .alert-dark, .alert-success, .alert-info, .alert-warning, .alert-danger):

Example

				
					<div class="alert alert-success">
  <strong>Success!</strong> Indicates a successful or positive action.
</div>
				
			

Alert Links

Create “matching colored links” by giving any links inside the alert box the alert-link class:

Success! You should read this message.
Info! You should read this message.
Warning! You should read this message.
Danger! You should read this message.
Primary! You should read this message.
Secondary! You should read this message.
Dark! You should read this message.
Light! You should read this message.

Example

				
					<div class="alert alert-success">
  <strong>Success!</strong> You should <a href="#" class="alert-link">read this message</a>.
</div>
				
			

Closing Alerts

==== LIVE ANIMATION MUKAVU ====

Include a .alert-dismissible class in the alert container to end the alert message. Next, give a link or button element class=”close” and data-dismiss=”alert” so that the alert box vanishes when a user clicks on it.

Example

				
					<div class="alert alert-success alert-dismissible">
  <button type="button" class="close" data-dismiss="alert">&times;</button>
  <strong>Success!</strong> Indicates a successful or positive action.
</div>
				
			

Tip: The HTML entity &times; (×) is the recommended icon for close buttons instead of the letter “x”.

See our HTML Entities Reference for a complete list of all HTML entities.

Animated Alerts

==== LIVE ANIMATION MUKAVU ====

A fading effect is added when the alert message is closed via the .fade and .show classes:

Example

				
					<div class="alert alert-danger alert-dismissible fade show">
				
			
Share this Doc

BS4 Alerts

Or copy link

Explore Topic