Flash Messages
Bootstrap 5 Flash Messages component
Responsive Flash messages built with the latest Bootstrap 5. Flash messages provide contextual feedback information for typical user actions with a handful of responsible and flexible messages boxes.
Basic examples
Click the buttons to launch the flash messages.
Static examples
Use .alert class
, followed by one of the contextual classes .alert-success
, .alert-info
,
.alert-warning
, .alert-danger
, .alert-primary
, .alert-secondary
, .alert-light
or .alert-dark
to create an flash message.
Icons
Use Font Awesome Icons to create flash messages with icons. Depending on your icons and content, you may want to add more utilities or custom styles.
Dismissing
Using the alert JavaScript plugin, it’s possible to dismiss any flash message inline. Here’s how:
- Be sure you’ve loaded the alert plugin or the compiled Bootstrap JavaScript.
-
Add a close button and the
.alert-dismissible
class, which adds extra padding to the right of the flash message and positions the close button. -
On the close button, add the
data-mdb-dismiss="alert"
attribute, which triggers the JavaScript functionality. Be sure to use thebutton
element with it for proper behavior across all devices. -
To animate flash messages when dismissing them, be sure to add the
.fade
and.show classes
.
You can see this in action with a live demo: