Skip to content

Toast

A lightweight notification: a background job that finished, a message from a teammate.

title, time and text render the header and the body, with a close button unless dismissible is false, as in the placement examples. For anything richer, such as an avatar before the title, compose it with Toast:Header, Toast:Body and Toast:Close, as above. Toast:Header takes the same title, time and dismissible.

Drop the header for a one-line message, and put the close button next to the body:

The toast does not position itself. Wrap toasts in a Toast:Container: it stacks them, and its placement pins the stack to a corner or the center of the viewport. Without placement, the container stays in the flow of its parent:

Without show, a toast stays hidden until Bootstrap shows it. With tabler.js, a trigger carrying data-bs-toggle="toast" and a data-bs-target shows it on click; from your own code, call bootstrap.Toast.getOrCreateInstance(element).show().

A shown toast hides itself after Bootstrap’s delay (5 seconds, set data-bs-delay to change it). autohide set to false keeps it until it is closed, as here:

A toast is a polite status message (role="status", aria-live="polite"): screen readers announce it once they are idle, as Tabler does since 1.7.1. urgent makes it an alert (role="alert", aria-live="assertive"), announced at once, interrupting the user: keep it for errors that matter.

Prop Type Default Description
show bool false Renders the toast visible (show)
autohide bool true false adds data-bs-autohide="false": the toast stays until it is closed
title string? null Rendered with Toast:Header and Toast:Title
time string? null Timestamp next to the title, rendered with Toast:Time
text string? null Rendered with Toast:Body
dismissible bool true Close button in the header rendered from title (Toast:Close)
urgent bool false role="alert" and aria-live="assertive" instead of status and polite

Other attributes go to the root <div class="toast">, such as the id a trigger targets.

Component Renders
Toast:Header <div class="toast-header">: the title, a time and the close button, see its props below
Toast:Title <strong class="me-auto">: the title, pushing the time and the close button to the end
Toast:Time <small class="text-secondary">: a timestamp, such as 2 min ago
Toast:Body <div class="toast-body">
Toast:Close The close button, <button class="ms-2 btn-close" data-bs-dismiss="toast"> (needs JS)
Toast:Container <div class="toast-container">: stacks toasts, see its props below
Prop Type Default Description
title string? null Rendered with Toast:Title
time string? null Rendered with Toast:Time
dismissible bool true Adds a close button (Toast:Close)
Prop Type Default Description
placement string? null top-start top-center top-end middle-center bottom-start bottom-center bottom-end

With a placement, the container gets position-fixed p-3 and the position utilities of that place (for instance top-0 end-0). Other attributes go to the container <div>.

Block Default
header Toast:Header with the title, time and dismissible props, when title is set
body Toast:Body with the text prop, when set
content header and body: replace it to compose freely

Toast:Header:

Block Default
title Toast:Title with the title prop, when set
time Toast:Time with the time prop, when set
close Toast:Close, when dismissible
content title, time and close: its children replace it