Components

Sonner

An opinionated toast notification system — render the Toaster once and fire transient messages from anywhere with the imperative toast() function.

Basic usage

Mount <Toaster /> once at the root of your app, then call toast() from any event handler.

Variants

Use toast.success, toast.error, toast.warning, and toast.info to add a leading status icon.

Descriptions, actions & promises

Pass a second options argument for a description and an action button, or use toast.promise to track an async task through loading, success, and error states.

Props

Props for the <Toaster /> provider. Per-toast options like description, action, and duration are passed to toast() directly.

PropTypeDefaultDescription
position'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right''bottom-right'Where toasts stack on the screen.
theme'light' | 'dark' | 'system''system'Color scheme of the toasts. Wired to next-themes by default.
richColorsbooleanfalseUse saturated success / error / warning colors instead of the neutral surface.
expandbooleanfalseExpand all stacked toasts on hover instead of collapsing them.
visibleToastsnumber3Maximum number of toasts visible at once.
closeButtonbooleanfalseRender a dismiss button on every toast.
durationnumber4000Default time in milliseconds a toast stays on screen.
offsetstring | number32Distance from the edges of the viewport.
gapnumber14Vertical gap between stacked toasts in pixels.
...restToasterPropsAll sonner Toaster props are forwarded.

Accessibility

  • Toasts are rendered into an aria-live region so screen readers announce new messages without moving focus.
  • Status messages use role="status" for polite announcements; never rely on color alone — keep the message text descriptive.
  • Hovering or focusing a toast pauses its auto-dismiss timer, giving users time to read and reach action buttons.
  • Press F6 to move focus to the toast region, then Tab to its action and close controls.