ui

Toast

Generates toast notifications. Built with Base UI and Tailwind CSS. Copy-paste ready.

API Reference

Installation

Add the ToastProvider and AnchoredToastProvider to your app.

app/layout.tsx

Usage

Stacked Toasts

By default, toasts appear in the bottom-right corner. You can change this by setting the position prop on the ToastProvider.

Allowed values: top-left, top-center, top-right, bottom-left, bottom-center, bottom-right. For example:

Anchored Toasts

For toasts positioned relative to a specific element, use anchoredToastManager. The AnchoredToastProvider is typically added to your app layout (alongside ToastProvider), so you can use anchoredToastManager directly in your components:

You can also style anchored toasts like tooltips by passing data: { tooltipStyle: true }. When using tooltip style, only the title is displayed (description and other content are ignored):

Examples

With Status

Pass a status of "success", "error", "warning", or "info" to render a colored icon and tinted background alongside the message.

Loading

A toast that starts with a loading spinner and transitions to success or error once the async operation resolves.

With Action

Includes an inline action button — commonly used for undo operations or quick-follow-up actions.

Promise

Pass a Promise to toastManager.promise to automatically show loading, success, and error states as the promise resolves or rejects.

With Varying Heights

Demonstrates how multiple stacked toasts of different content lengths collapse and expand smoothly in the stack.

Form Submit

A form submit button that shows a success toast on completion and an error toast if the operation fails, without a page reload.

Staggered Burst

Four toasts fire with staggered delays (0 / 800 / 1600 / 2400 ms) so they animate into the stack one after another. The trigger button is disabled while the burst is in progress.

Timeout Control

Demonstrates the three common timeout modes: a 3-second auto-dismiss, an 8-second extended toast, and a persistent toast (timeout 0) that requires an explicit "Dismiss" action button.

Deploy Pipeline

A chained sequence of toasts that progress through a deploy flow — loading → tests passed → deployed. Each stage closes the previous toast by ID before opening the next.

Anchored Copy Toast

Uses anchoredToastManager with tooltipStyle: true to pop a "Copied!" tooltip directly above a copy button — no full notification stack needed.

Invite with Undo

Each team invite fires a success toast with an Undo action. Clicking Undo closes the toast, removes the invite, and fires an info toast confirming the revocation.

Background Export

An Export to CSV button triggers a loading toast while work runs in the background. When complete, it closes the loading toast and opens a success toast with a Download action.

Session Expiry Warning

Simulates a session timeout: a persistent warning toast appears with a live countdown and a "Renew session" action. If ignored the timer reaches zero and an error toast replaces it.

Unsaved Changes

A persistent "Unsaved changes" warning toast appears when the document is edited. The inline "Save now" action and the explicit Save button both resolve the toast and confirm with a success notification.