Toast
Imperative notification system based on sonner — auto-dismiss, stacking, six positions, and a typed action slot.
At a glance
- Mount
<Toaster />exactly once near your app root, then call the imperativetoast(...)from anywhere. - Tone-specific shortcuts:
toast.success,toast.error,toast.warning,toast.info, plustoast.dismiss(id?)andtoast.promise(...). - Web: powered by sonner — full feature set including swipe-to-dismiss, screen-reader live region, and rich colors.
- Native: matched API surface with the same six positions, swipe-to-dismiss, auto-dismiss, and stacking. No
if (Platform.OS === 'web')in your code. - Six positions:
top-left,top-center(default),top-right,bottom-left,bottom-center,bottom-right. The global anchor lives on<Toaster position>; any individual call may override withtoast(msg, { position }). durationdefaults to 4000ms. PassInfinityto keep a toast open until dismissed manually.
Mount the Toaster once
The docs site mounts a single <Toaster richColors /> at the root — that's why every demo on this page uses the saturated tone surface. richColors is a Toaster-level flag, not a per-call option.
Tones, action, promise
All five tones plus an inline action button and toast.promise for async flows. Click "Promise" and watch the same card swap from the loading state to success after 1.5s.
Per-call position override
The global <Toaster position> sets the default anchor; any single call can override it with toast(msg, { position: 'bottom-right' }). Useful for one-off toasts that belong somewhere different from the rest of your UI.
Update an existing toast in place
Reuse the same id to swap a loading toast for a success/error one without spawning a second card. Useful when toast.promise doesn't fit the flow — chained calls, intermediate progress states, or backend events that arrive asynchronously.
API
options accepts description, duration, action, cancel, tone, id, position, icon, className. Each call returns the toast's id — pass it to toast.dismiss(id) later or to toast(title, { id }) to update the existing entry.
<Toaster> props
The mount point is configured once near your app root. The most common knobs:
position— global default anchor.expand— keep stacked toasts visible at full size instead of collapsing them. Defaultfalse.gap— vertical gap between stacked toasts in pixels. Default14.offset— distance from the chosen edge of the screen. Accepts a number (px) or a CSS string. Default16.visibleToasts— maximum number of toasts shown at once. Older ones queue and pop in as space frees up. Default3.closeButton— render a small ✕ on every toast. Defaultfalse. Per-call swipe-to-dismiss still works either way.richColors— saturated tone surfaces (used on this docs site). Defaultfalse.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
closeButton | boolean | — | Show a small close button in the top-right corner of each toast. @defaultValue false |
duration | number | — | Default duration in ms for toasts that don't pass their own. @defaultValue 4000 |
expand | boolean | — | Web only: expand the stack on hover (sonner's `expand`). Native always renders the visible toasts uncollapsed, so this is a no-op there. @defaultValue false |
gap | number | — | Spacing between stacked toasts in px. @defaultValue 14 |
offset | number | — | Pad the toaster away from the viewport edges by this many px. @defaultValue 24 |
position | enum | — | Where the toast stack anchors. @defaultValue 'top-center' |
richColors | boolean | — | Web only: full-color toasts per tone (sonner's `richColors`). On native this is honored visually too, with the same palette recipe. @defaultValue false |
visibleToasts | number | — | Maximum number of toasts visible at once. Older toasts collapse behind newer ones (web) or pop off the top of the stack (native). @defaultValue 3 |