Skip to content

Toast

Short, non-blocking notifications — queued from anywhere, announced to screen readers, dismissed automatically.

Styled with CSS Tailwind

Simple toast

Inject BitBhToaster (registered by AddBitBheadlessServices()) and call Show. Toasts appear in a BitBhToastViewport — a role="region" landmark labelled "Notifications (F8)"; press F8 to jump to it. Every toast is announced through the shared live region, auto-dismisses after the viewport's Duration (paused while hovered or focused) and closes with Escape or a BitBhToastClose. Toasts emit data-state="open|closed" and the exit animation is awaited before removal: the CSS version animates them with keyframes on [data-state], the Tailwind version with starting: and data-state-closed: transitions.

With a description

Pass a description and render it with BitBhToastDescription. Title and description are announced together ("Changes saved. Your profile is now visible…"). Data carries anything your template needs — here a variant that picks the icon and is set as data-variant on the toast.

With an action

Set ActionLabel and OnAction; BitBhToastAction renders the button, runs the callback and dismisses the toast. Toasts disappear, so keep the action reachable elsewhere too — here "Restore all" stays on the page.

  • Quarterly report
  • Team offsite plan
  • Invoice #1042

Foreground (assertive) error

Toasts are background (role="status", announced politely) by default. Set Foreground = true for the direct result of a user action that needs attention: it is announced assertively (role="alert") and the toast gets data-type="foreground".

Custom duration and persistent toasts

Duration (ms) on a toast overrides the viewport's default (5000 ms). Duration = 0 keeps the toast until it is dismissed. Clear() dismisses every toast.

Stacking with Limit

BitBhToaster.Limit (default 5) caps how many toasts are kept — the oldest is dropped when a new one arrives. This demo creates its own toaster with Limit = 3 and renders it in a second viewport (passed through Toaster, bottom-left, Shift+F8) styled as a stack: the toasts overlap in one grid cell and fan out on hover or keyboard focus. The CSS version offsets the older toasts with :nth-last-child; the Tailwind version picks per-depth utilities from each toast's position in Toasts.

Shown: 0 of max 3

Promise toasts, updates and swiping

PromiseAsync shows a "loading" toast while a task runs and turns the same toast into "success" or "error" (data-variant) when it completes; Show with the Id of a toast still shown, or Update, changes a toast in place - it restarts its timer and is announced again. Swipe a toast to the right to dismiss it (SwipeDirection; data-swipe and --bit-bh-toast-swipe-move-x while dragged). Timers pause while the toasts are hovered or focused and while the page is hidden.

      An unhandled error has occurred. Reload 🗙