<div class="toast toast-show fade show" role="alert" aria-live="assertive" aria-atomic="true">
<div class="toast-header">
<div class="d-flex align-items-center flex-grow-1">
<div class="flex-shrink-0">
<img class="avatar avatar-sm avatar-circle" src="../../assets/img/user-03.png" alt="Image description">
</div>
<div class="flex-grow-1 ms-3">
<h5 class="mb-0 fs-6">Bob Dean</h5>
<small class="ms-auto">11 mins ago</small>
</div>
<div class="text-end">
<button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
</div>
</div>
</div>
<div class="toast-body">
Hello, world! This is a toast message.
</div>
</div>
Click the button the below to show as toast (positioning with our utilities in the lower right corner) that has been hidden by default with .hide
.
<button id="liveToastBtn" class="btn btn-primary">Toast</button>
<!-- Toast -->
<div id="liveToast" class="position-fixed toast hide" role="alert" aria-live="assertive" aria-atomic="true" style="top: 20px; right: 20px; z-index: 1000;">
<div class="toast-header">
<div class="d-flex align-items-center flex-grow-1">
<div class="flex-shrink-0">
<img class="avatar avatar-sm avatar-circle" src="../../assets/img/user-03.png" alt="Image description">
</div>
<div class="flex-grow-1 ms-3">
<h5 class="mb-0 fs-6">Bob Dean</h5>
<small class="ms-auto">11 mins ago</small>
</div>
<div class="text-end">
<button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
</div>
</div>
</div>
<div class="toast-body">
Hello, world! This is a toast message.
</div>
</div>
// INITIALIZATION OF LIVE TOAST
var toastTrigger = document.getElementById('liveToastBtn')
var toastLiveExample = document.getElementById('liveToast')
if (toastTrigger) {
toastTrigger.addEventListener('click', function () {
var toast = new bootstrap.Toast(toastLiveExample)
toast.show()
})
}
When you have multiple toasts, we default to vertically stacking them in a readable manner.
<div class="toast-container">
<!-- Toast -->
<div class="toast toast-show fade show" role="alert" aria-live="assertive" aria-atomic="true">
<div class="toast-header">
<div class="d-flex align-items-center flex-grow-1">
<div class="flex-shrink-0">
<img class="avatar avatar-sm avatar-circle" src="../../assets/img/user-01.png" alt="Image description">
</div>
<div class="flex-grow-1 ms-3">
<h5 class="mb-0 fs-6">Bob Dean</h5>
<small class="ms-auto">11 mins ago</small>
</div>
<div class="text-end">
<button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
</div>
</div>
</div>
<div class="toast-body">
See? Just like this.
</div>
</div>
<!-- End Toast -->
<!-- Toast -->
<div class="toast toast-show fade show" role="alert" aria-live="assertive" aria-atomic="true">
<div class="toast-header">
<div class="d-flex align-items-center flex-grow-1">
<div class="flex-shrink-0">
<img class="avatar avatar-sm avatar-circle" src="../../assets/img/user-03.png" alt="Image description">
</div>
<div class="flex-grow-1 ms-3">
<h5 class="mb-0 fs-6">Ella Lauda</h5>
<small class="ms-auto">20 mins ago</small>
</div>
<div class="text-end">
<button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
</div>
</div>
</div>
<div class="toast-body">
Heads up, toasts will stack automatically
</div>
</div>
<!-- End Toast -->
</div>
Place toasts with custom CSS as you need them. The top right is often used for notifications, as is the top middle. If you’re only ever going to show one toast at a time, put the positioning styles right on the .toast
.
<div aria-live="polite" aria-atomic="true" style="position: relative; min-height: 200px;">
<div class="toast toast-show fade show" role="alert" aria-live="assertive" aria-atomic="true" style="position: absolute; top: 0; right: 0;">
<div class="toast-header">
<div class="d-flex align-items-center flex-grow-1">
<div class="flex-shrink-0">
<img class="avatar avatar-sm avatar-circle" src="../../assets/img/user-03.png" alt="Image description">
</div>
<div class="flex-grow-1 ms-3">
<h5 class="mb-0 fs-6">Bob Dean</h5>
<small class="ms-auto">11 mins ago</small>
</div>
<div class="text-end">
<button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
</div>
</div>
</div>
<div class="toast-body">
Hello, world! This is a toast message.
</div>
</div>
</div>