Toaster
moleculesBottom-centred toast stack fed by the toasts store: five tones, timed or sticky, an optional async action with a close button beside it, undo with optimistic apply, a one-row status toast updated in place (reconnecting, offline, syncing) that can pin to the top, pause on hover, swipe sideways on touch to dismiss, moves into an open modal.
Save, publish and delete with undo
mount one <Toaster /> at the app root (this page already does); call toasts.show/ok/error/info from anywhere. toasts.undo applies the change at once, offers Undo while the toast is visible and commits when it goes away; a failed commit reverts and explains.
- Invoice #4821 is ready
- Build 0.82 passed on main
- Weekly digest: 14 new issues
- Your export finished
Tones
neutral, ok, info, warn and error (danger is an alias); errors go to the assertive live region.
Timed, sticky, stacking, long text, failing action
duration in ms (0 = sticky until clicked or dismissed by id); a throwing action.run becomes an error toast; hover pauses the timer.
Over an open modal
while a modal <dialog> is open the stack moves inside it so toasts stay visible and clickable, then returns to the root on close.
Position
<Toaster position="left" | "center" | "right" /> picks the side of the edge the stack hugs. The page mounts its Toaster outside this example, so the control sets the data-position that prop renders.
Status: reconnecting with countdown and Retry
toasts.status() is a sticky one-row toast (warn tone, busy spinner, muted detail) that toasts.update() keeps current in place: the countdown ticks in the detail without a re-announce, a busy attempt shows Retry pending and drops the close button and swipe. placement: "top" pins it under --toaster-offset-top while other toasts stay put.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
placement | 'bottom' | 'bottom-start' | 'bottom-end' | 'top' | 'bottom' | Where the stack sits; bottom placements clear the bottom bars. |
position | 'left' | 'center' | 'right' | — | Which side of that edge the stack hugs. Defaults to the side `placement` names (`bottom-start` left, `bottom-end` right), otherwise the centre. |
class | string | '' | |
style | string | '' | |
sound | boolean | true | Play UI sounds when enabled globally; false silences this instance. |
label | string | 'Notifications' | Accessible name of the region holding both live regions. |