Toast
The region where toasts appear: short messages, queued, that go by themselves, with an optional action, swiped away or dismissed.
Stability: experimental
Props
| Prop | Type | Default | Means |
|---|---|---|---|
position | "top" | "bottom" | bottom | Which edge of the window the toasts stack at. |
label | string | Notifications | The region's accessible name. |
States
| State | Looks like |
|---|---|
neutral | Body text in the surface colour on an ink background, a large radius and shadow; up to 440px wide, centred. |
success | A check-circle icon in the success colour. |
danger | The danger background, an alert icon, and the action underlined. |
with action | A primary-coloured text button, such as Undo, before the dismiss button. |
queued | Three toasts show at once, oldest first; the rest wait and show as earlier ones go. |
swiping | The toast follows the pointer sideways and fades; past 72px it is dismissed. |
entering | Rises 12px and fades in over 200 ms; at once with reduced motion. |
Accessibility
| role | region with aria-live="polite"; a danger toast is an alert (assertive) |
| name | The label prop (aria-label); each toast by its message. |
| focus | Never takes focus. Its buttons are in the Tab order, after the screen; while focus or the pointer is in the region, the toasts pause, so none leaves while it is being read or used. |
| keyboard | Enter or Space on a toast's action or Dismiss button. |
| notes | A toast goes after 5 seconds (8 with an action) unless duration says otherwise; the time left is kept while paused. The region stays above modals and is never made inert. |
Theme tokens
color.ink color.surface color.success color.danger color.on-primary color.primary shadow.lg radius.lg radius.sm radius.full space.2 space.3 space.4 text.body text.label
Example
<Toast /> placed once, then toast("Saved") or toast("Deleted", { action: { label: "Undo", onPress: undo } }) from @duolith/client.