Toasts
Things to know when using the toast plugin.
- Toasts are opt-in for performance reasons, so you must initialize them yourself.
- Toasts will automatically hide if you do not specify
autohide: false
.
<div class="toast fade show" role="alert" aria-live="assertive" aria-atomic="true">
<div class="toast-header">
<img src="../assets/images/xs/avatar1.jpg" class="avatar sm rounded me-2" alt="" />
<strong class="me-auto">Bootstrap</strong>
<small>11 mins ago</small>
<button type="button" class="btn-close" data-dismiss="toast" aria-label="Close"></button>
</div>
<div class="toast-body">
Hello, world! This is a toast message.
</div>
</div>
Basic Example
Stacking
You can stack toasts by wrapping them in a toast container, which will vertically add some spacing.
Custom content
Customize your toasts by removing sub-components, tweaking with utilities, or adding your own markup. Here we’ve created a simpler toast by removing the default .toast-header
, adding a custom hide icon from Bootstrap Icons, and using some flexbox utilities to adjust the layout.
Building on the above example, you can create different toast color schemes with our color utilities. Here we’ve added .bg-primary
and .text-white
to the .toast
, and then added .text-white
to our close button. For a crisp edge, we remove the default border with .border-0
.
Alternatively, you can also add additional controls and components to toasts.