Skip to content

Toast

Transient, non-blocking notifications fired imperatively from anywhere in the app.

  • stable
  • since v0.1.0
  • 10.1 kB
  • overlay
  • feedback
  • accessible

Renders inside a polite aria-live region; error toasts use assertive; toasts never trap focus and never block interaction with the underlying page.

Preview
Open
tsx

Each variant has its own icon and color scheme — success, error, warning, info, plus the plain default.

Preview
Open
tsx

Pass a description for a second muted line under the title.

Preview
Open
tsx

Add an action for an undo-style affordance. The action button is keyboard-reachable inside the toast.

Preview
Open
tsx

Toaster accepts position="top-left" | "top-center" | "top-right" | "bottom-left" | "bottom-center" | "bottom-right" (default). Set it once at the root.

Preview
Open
tsx
PropTypeDefaultDescription
toastOptions
ToastOptions
Sonner `toastOptions`. Merged with Cynosure's token-derived class names — consumer `classNames` are applied on top of the defaults, so any key you set wins for that slot.
  • Toasts render inside an aria-live="polite" region so screen readers announce them without interrupting the user.
  • toast.error is announced assertively so failures cut through other speech.
  • Toasts never trap focus — the rest of the page remains fully interactive.
  • The optional close button (closeButton is on by default) is keyboard-reachable for users who want to dismiss before the timeout.
  • Keep titles short and descriptive — they are the first thing announced.
  • Render <Toaster /> exactly once, as high in the React tree as possible.
  • Use toast.success / toast.error for status-specific styling and ARIA politeness rather than coloring a default toast manually.
  • Tune duration per call for important messages: toast(msg, { duration: 8000 }).
  • Keep copy short — one line in the title, one in the description. Route long content to a Dialog.