Bootstrap 5 Alerts
Display pre-styled alerts and messages for common user actions.
Bootstrap provides an easy way to create a stylized alert message box with its alert component.
To create an alert box, use the .alert
class along with one of the .alert-*
classes to specify the kind of alert.
Dismissible Alerts
You can create dismissible alerts by adding a close button and the .alert-dismissible
class. On the close button, add the data-bs-dismiss="alert"
attribute. Be sure to use the button
element with it for proper behavior across all devices.
Fading Effect
You can give the alert a slight fading effect when closing them by adding the .fade
and .show
classes.
Alerts with Links
Use Bootstrap's .alert-link
class on the a
tag to match link color with the text.