Duolith docs

Toast

The region where toasts appear: short messages, queued, that go by themselves, with an optional action, swiped away or dismissed.

Stability: experimental

Props

PropTypeDefaultMeans
position"top" | "bottom"bottomWhich edge of the window the toasts stack at.
labelstringNotificationsThe region's accessible name.

States

StateLooks like
neutralBody text in the surface colour on an ink background, a large radius and shadow; up to 440px wide, centred.
successA check-circle icon in the success colour.
dangerThe danger background, an alert icon, and the action underlined.
with actionA primary-coloured text button, such as Undo, before the dismiss button.
queuedThree toasts show at once, oldest first; the rest wait and show as earlier ones go.
swipingThe toast follows the pointer sideways and fades; past 72px it is dismissed.
enteringRises 12px and fades in over 200 ms; at once with reduced motion.

Accessibility

roleregion with aria-live="polite"; a danger toast is an alert (assertive)
nameThe label prop (aria-label); each toast by its message.
focusNever 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.
keyboardEnter or Space on a toast's action or Dismiss button.
notesA 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.