Components
Toasts
Lightweight notifications shown from a button with the Popover API — placed, stacked and faded by CSS.
How it works
A live toast is a <div class="toast" popover="manual">. A button with
popovertarget and popovertargetaction="show" opens it in the top layer; its close
button uses popovertargetaction="hide". popover="manual" means a click elsewhere
does not dismiss it, which is what a notification wants.
- Baseline: Popover API (Chrome 114, Safari 17, Firefox 125). Static toasts with
.showwork everywhere. - Enhancement:
.fadeanimates the opacity in with@starting-style. - Enhancement:
.toast-autohidefades the toast out after--bs-toast-delay— a CSS animation, see Auto-hide for the catch. - Fallback: a static
.toast.showplaced in markup by the server.
.toast.show
with a close button that is a plain link.Basic
The anatomy: .toast-header with a title, timestamp and close button, then
.toast-body. Static toasts carry .show; without it, .toast is
display: none.
HTML
<div class="toast show" role="alert" aria-live="assertive" aria-atomic="true">
<div class="toast-header">
<svg class="rounded me-2" width="20" height="20" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><rect width="100%" height="100%" fill="#b8941f"></rect></svg>
<strong class="me-auto">Bootstrap</strong>
<small>11 mins ago</small>
<button type="button" class="btn-close" aria-label="Close"></button>
</div>
<div class="toast-body">
Hello, world! This is a toast message.
</div>
</div>Live example
Press the button. The toast appears bottom-right (the default placement for a popover toast) and stays until closed.
HTML
<button type="button" class="btn btn-primary" popovertarget="toasts-live" popovertargetaction="show">Show live toast</button>
<div class="toast fade" popover="manual" id="toasts-live" role="status" aria-live="polite" aria-atomic="true">
<div class="toast-header">
<svg class="rounded me-2" width="20" height="20" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><rect width="100%" height="100%" fill="#b8941f"></rect></svg>
<strong class="me-auto">Bootstrap</strong>
<small>11 mins ago</small>
<button type="button" class="btn-close" popovertarget="toasts-live" popovertargetaction="hide" aria-label="Close"></button>
</div>
<div class="toast-body">
Hello, world! This is a toast message.
</div>
</div>
Because the toast is a popover, it can sit anywhere in the DOM — put it next to the button or at the end of
<body>. Pressing "show" on a toast that is already open does nothing; closing it first
resets it.
Translucent
Toasts are slightly translucent (--bs-toast-bg is the body background at 85 % opacity), so
they blend over whatever is beneath. On a dark region, wrap the toast in data-bs-theme="dark".
HTML
<div class="toast show" role="alert" aria-live="assertive" aria-atomic="true" data-bs-theme="dark">
<div class="toast-header">
<svg class="rounded me-2" width="20" height="20" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><rect width="100%" height="100%" fill="#e6c769"></rect></svg>
<strong class="me-auto">Bootstrap</strong>
<small class="text-body-secondary">11 mins ago</small>
<button type="button" class="btn-close" aria-label="Close"></button>
</div>
<div class="toast-body">
Hello, world! This is a toast message.
</div>
</div>Stacking
Static toasts stack when wrapped in .toast-container; it spaces them with
--bs-toast-spacing.
HTML
<div class="toast-container position-static">
<div class="toast show" role="alert" aria-live="assertive" aria-atomic="true">
<div class="toast-header">
<svg class="rounded me-2" width="20" height="20" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><rect width="100%" height="100%" fill="#b8941f"></rect></svg>
<strong class="me-auto">Bootstrap</strong>
<small class="text-body-secondary">just now</small>
<button type="button" class="btn-close" aria-label="Close"></button>
</div>
<div class="toast-body">
See? Just like this.
</div>
</div>
<div class="toast show" role="alert" aria-live="assertive" aria-atomic="true">
<div class="toast-header">
<svg class="rounded me-2" width="20" height="20" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><rect width="100%" height="100%" fill="#b8941f"></rect></svg>
<strong class="me-auto">Bootstrap</strong>
<small class="text-body-secondary">2 seconds ago</small>
<button type="button" class="btn-close" aria-label="Close"></button>
</div>
<div class="toast-body">
Heads up, toasts will stack automatically
</div>
</div>
</div>
A live stack is a .toast-container that is itself the popover. The toasts inside use
.show, and position utilities place the container. Any close button hides the whole stack —
individual toasts cannot be dismissed on their own this way.
HTML
<button type="button" class="btn btn-primary" popovertarget="toasts-stack" popovertargetaction="show">Show a stack</button>
<div class="toast-container position-fixed bottom-0 end-0 p-4" popover="manual" id="toasts-stack">
<div class="toast show" role="status" aria-live="polite" aria-atomic="true">
<div class="toast-header">
<strong class="me-auto">Ring crew</strong>
<small class="text-body-secondary">just now</small>
<button type="button" class="btn-close" popovertarget="toasts-stack" popovertargetaction="hide" aria-label="Close"></button>
</div>
<div class="toast-body">Turnbuckle pads replaced.</div>
</div>
<div class="toast show" role="status" aria-live="polite" aria-atomic="true">
<div class="toast-header">
<strong class="me-auto">Production</strong>
<small class="text-body-secondary">2 seconds ago</small>
<button type="button" class="btn-close" popovertarget="toasts-stack" popovertargetaction="hide" aria-label="Close"></button>
</div>
<div class="toast-body">Pyro test at 6:45.</div>
</div>
</div>Custom content
Drop the header and use flex utilities for a compact toast.
HTML
<div class="toast show align-items-center" role="alert" aria-live="assertive" aria-atomic="true">
<div class="d-flex">
<div class="toast-body">
Hello, world! This is a toast message.
</div>
<button type="button" class="btn-close me-2 m-auto" aria-label="Close"></button>
</div>
</div>Or add controls in the body.
HTML
<div class="toast show" role="alert" aria-live="assertive" aria-atomic="true">
<div class="toast-body">
Hello, world! This is a toast message.
<div class="mt-2 pt-2 border-top">
<button type="button" class="btn btn-primary btn-sm">Take action</button>
<button type="button" class="btn btn-secondary btn-sm">Close</button>
</div>
</div>
</div>Color schemes
.text-bg-* and .border-0 colour a toast. The primary variant is gold with navy
text; .text-bg-navy is cream on navy. On a dark fill add .btn-close-white.
HTML
<div class="toast show align-items-center text-bg-primary border-0 mb-4" role="alert" aria-live="assertive" aria-atomic="true">
<div class="d-flex">
<div class="toast-body">
Hello, world! This is a toast message.
</div>
<button type="button" class="btn-close me-2 m-auto" aria-label="Close"></button>
</div>
</div>
<div class="toast show align-items-center text-bg-navy border-0" role="alert" aria-live="assertive" aria-atomic="true">
<div class="d-flex">
<div class="toast-body">
Bell time moved to 7:30.
</div>
<button type="button" class="btn-close btn-close-white me-2 m-auto" aria-label="Close"></button>
</div>
</div>Placement
A popover toast defaults to the bottom-end corner, inset by --bs-toast-offset (1rem). Six
classes move it: .toast-top-start, .toast-top-center, .toast-top-end,
.toast-middle-center, .toast-bottom-start and .toast-bottom-center.
HTML
<button type="button" class="btn btn-outline-primary" popovertarget="toasts-ts" popovertargetaction="show">Top start</button>
<button type="button" class="btn btn-outline-primary" popovertarget="toasts-tc" popovertargetaction="show">Top center</button>
<button type="button" class="btn btn-outline-primary" popovertarget="toasts-te" popovertargetaction="show">Top end</button>
<button type="button" class="btn btn-outline-primary" popovertarget="toasts-mc" popovertargetaction="show">Middle center</button>
<button type="button" class="btn btn-outline-primary" popovertarget="toasts-bs" popovertargetaction="show">Bottom start</button>
<button type="button" class="btn btn-outline-primary" popovertarget="toasts-bc" popovertargetaction="show">Bottom center</button>
<button type="button" class="btn btn-outline-primary" popovertarget="toasts-be" popovertargetaction="show">Bottom end (default)</button>
<div class="toast fade toast-top-start" popover="manual" id="toasts-ts" role="status" aria-live="polite" aria-atomic="true">
<div class="d-flex"><div class="toast-body">Top start</div><button type="button" class="btn-close me-2 m-auto" popovertarget="toasts-ts" popovertargetaction="hide" aria-label="Close"></button></div>
</div>
<div class="toast fade toast-top-center" popover="manual" id="toasts-tc" role="status" aria-live="polite" aria-atomic="true">
<div class="d-flex"><div class="toast-body">Top center</div><button type="button" class="btn-close me-2 m-auto" popovertarget="toasts-tc" popovertargetaction="hide" aria-label="Close"></button></div>
</div>
<div class="toast fade toast-top-end" popover="manual" id="toasts-te" role="status" aria-live="polite" aria-atomic="true">
<div class="d-flex"><div class="toast-body">Top end</div><button type="button" class="btn-close me-2 m-auto" popovertarget="toasts-te" popovertargetaction="hide" aria-label="Close"></button></div>
</div>
<div class="toast fade toast-middle-center" popover="manual" id="toasts-mc" role="status" aria-live="polite" aria-atomic="true">
<div class="d-flex"><div class="toast-body">Middle center</div><button type="button" class="btn-close me-2 m-auto" popovertarget="toasts-mc" popovertargetaction="hide" aria-label="Close"></button></div>
</div>
<div class="toast fade toast-bottom-start" popover="manual" id="toasts-bs" role="status" aria-live="polite" aria-atomic="true">
<div class="d-flex"><div class="toast-body">Bottom start</div><button type="button" class="btn-close me-2 m-auto" popovertarget="toasts-bs" popovertargetaction="hide" aria-label="Close"></button></div>
</div>
<div class="toast fade toast-bottom-center" popover="manual" id="toasts-bc" role="status" aria-live="polite" aria-atomic="true">
<div class="d-flex"><div class="toast-body">Bottom center</div><button type="button" class="btn-close me-2 m-auto" popovertarget="toasts-bc" popovertargetaction="hide" aria-label="Close"></button></div>
</div>
<div class="toast fade" popover="manual" id="toasts-be" role="status" aria-live="polite" aria-atomic="true">
<div class="d-flex"><div class="toast-body">Bottom end</div><button type="button" class="btn-close me-2 m-auto" popovertarget="toasts-be" popovertargetaction="hide" aria-label="Close"></button></div>
</div>
For static toasts, place a .toast-container with position utilities
inside a positioned parent, exactly as in stock Bootstrap.
HTML
<div class="position-relative bg-body-secondary rounded" style="min-height: 240px;" aria-live="polite" aria-atomic="true">
<div class="toast-container position-absolute top-0 end-0 p-4">
<div class="toast show" role="alert" aria-atomic="true">
<div class="toast-header">
<strong class="me-auto">Bootstrap</strong>
<small>11 mins ago</small>
<button type="button" class="btn-close" aria-label="Close"></button>
</div>
<div class="toast-body">
Hello, world! This is a toast message.
</div>
</div>
</div>
</div>Auto-hide
.toast-autohide fades the toast out after --bs-toast-delay (default 5s). This is a
CSS animation on :popover-open, so it is visual only: the popover is still open
after it fades. A button with popovertargetaction="show" would then do nothing, so use the
default toggle action — the next press silently closes the invisible toast and the press after that
shows it again. Keep a close button too.
HTML
<button type="button" class="btn btn-primary" popovertarget="toasts-autohide">Show auto-hiding toast</button>
<div class="toast fade toast-autohide" popover="manual" id="toasts-autohide" role="status" aria-live="polite" aria-atomic="true" style="--bs-toast-delay: 4s">
<div class="toast-header">
<strong class="me-auto">Countdown</strong>
<small>4 seconds</small>
<button type="button" class="btn-close" popovertarget="toasts-autohide" popovertargetaction="hide" aria-label="Close"></button>
</div>
<div class="toast-body">Fades out on its own. Under reduced motion it disappears at the delay instead of fading.</div>
</div>Accessibility
- Use
role="status"+aria-live="polite"for information androle="alert"+aria-live="assertive"for things that need attention. Addaria-atomic="true"so the whole toast is read. - Because a popover toast is
display: noneuntil shown, some screen readers announce it only when its content changes. Put the live-region attributes on a permanent wrapper (as in the static placement example) if announcements matter. - The close button must be a real button with
popovertargetaction="hide". - Toasts with a close button that the user cannot find in time are a failure. Do not auto-hide anything the user must act on.
- Dark mode: the background and header use
--bs-body-bg, so toasts followdata-bs-themeand the system scheme.
CSS
All of Bootstrap's --bs-toast-* variables apply, plus two of the theme's:
.toast {
--bs-toast-zindex: 300;
--bs-toast-padding-x: 0.75rem;
--bs-toast-padding-y: 0.5rem;
--bs-toast-spacing: 1.5rem;
--bs-toast-max-width: 350px;
--bs-toast-font-size: 0.875rem;
--bs-toast-color: ;
--bs-toast-bg: rgba(var(--bs-body-bg-rgb), 0.85);
--bs-toast-border-width: var(--bs-border-width);
--bs-toast-border-color: var(--bs-border-color-translucent);
--bs-toast-border-radius: 2px;
--bs-toast-box-shadow: var(--bs-box-shadow);
--bs-toast-header-color: var(--bs-secondary-color);
--bs-toast-header-bg: rgba(var(--bs-body-bg-rgb), 0.85);
--bs-toast-header-border-color: var(--bs-border-color-translucent);
}
.toast[popover] {
--bs-toast-offset: 1rem; /* distance from the viewport edge */
}
.toast-autohide:popover-open {
--bs-toast-delay: 5s; /* set inline per toast */
}
Behavioural selectors:
.toast:not(.show) // static toasts hidden until .show
.toast[popover]:popover-open // live toast: position fixed, display block
.toast-container[popover]:popover-open // live stack
.toast-top-start … .toast-bottom-center // placement of a popover toast
.toast.fade:popover-open // fade in via @starting-style
.toast-autohide:popover-open // rb-toast-autohide keyframes, 85 % hold then fade