ToastProvider and useToast confirm something that just happened: a slab pill at the bottom centre with a glyph disc, a title, an optional line and one action. One shows at a time and three wait their turn; each lives 5.2 s, and the time holds while the region is hovered or focused or the window is in the background. A toast never holds an error's only copy and never asks for a decision.
Example#
Usage#
Use a toast to confirm something that just happened and needs no answer: "Draft archived", "Link copied". It prints on a slab pill at the bottom centre, above the action dock on phones.
- One at a time. One shows, three wait; each lives 5.2 s, and the time holds while the region is hovered or focused or the window is in the background.
- One action at most, such as "Undo", as a small secondary key.
- Never an error's only copy, and never a question: errors live next to what caused them, decisions in a
Dialog. - Set up once.
ToastProviderwraps the app;useToast()returnstoast({ title, description, action, glyph }).
Anatomy#
Draft archived
- PillThe slab, at least 52 px tall.
.mk-toast - Glyph discA 26 px paper disc with the ink glyph.
data-mk-part="disc" - WordsThe title, and an optional line in the second slab ink.
data-mk-part="text" - DismissA quiet key; the region is reachable with F6.
.mk-toast-close
Volume#
Reading layer: identical at every volume.
Quiet
Draft archived
Studio
Draft archived
Press
Draft archived
Rave
Draft archived
Content#
- Past tense, the thing first: "Draft archived", "Link copied".
- Two to four words; a second line only when it adds something, such as where the thing went.
- The action is one verb: "Undo", "View".
Do and don't#
Do
Draft archived
Don't
A toast saying "Payment failed. Try another card." that disappears in five seconds.
Accessibility#
- A polite live region; F6 moves focus to the region and the timers hold while it has focus.
- The drain bar along the foot reads time, so it still runs under reduced motion; the rise and drop become a fade.
- It sits above the phone dock through
--mk-dock-h.
| Keys | What happens |
|---|---|
| F6 | Moves focus to the notifications region (timers hold while it has focus) |
| Tab | Moves to the toast's action and close keys |
| EnterorSpace | Runs the action or closes the toast |
The colour pairs it prints, with their contrast on both papers:
| Text | Surface | Role | Bone | Night |
|---|---|---|---|---|
--mk-on-slab | --mk-slab | label | 16.49:1 · Lc 98.7, passes | 16.21:1 · Lc 95.1, passes |
--mk-on-slab | --mk-slab | body-ui | 16.49:1 · Lc 98.7, passes | 16.21:1 · Lc 95.1, passes |
--mk-on-slab | --mk-slab | long | 16.49:1 · Lc 98.7, passes | 16.21:1 · Lc 95.1, passes |
--mk-on-slab-2 | --mk-slab | meta | 11.51:1 · Lc 75.1, passes | 6.29:1 · Lc 75.2, passes |
Props#
| Prop | Type | Default | Description |
|---|---|---|---|
children required | ReactNode | none | |
timeout | number | none | Default life in ms (5200, `--mk-dur-toast-life`). |
queue | number | 3 | How many may wait behind the shown one (default 3). |
closeLabel | string | none | |
label | string | "Notifications" | The region's name (default "Notifications"). |
Tokens#
System tokens (19)
--mk-border--mk-dur-reduced--mk-dur-toast-in--mk-dur-toast-out--mk-ease-out--mk-font-text--mk-on-slab--mk-on-slab-2--mk-shadow-toast--mk-slab--mk-space-1--mk-surface--mk-text--mk-text-2--mk-type-control-sm-size--mk-type-meta-leading--mk-type-meta-size--mk-type-meta-weight--mk-z-toast
Its own properties (7)
--mk-dock-h--mk-toast-gap--mk-toast-leading--mk-toast-life--mk-toast-line-gap--mk-toast-pad--mk-toast-pad-start
Changelog#
Arrived in 0.9.0.
ComboboxandComboboxItem(a case- and accent-insensitive filter by default, groups, chips formultiple, "Searching…", an empty message, a live result count, andinlinefor a list printed in place),PopoverwithPopoverTrigger,PopoverContentandPopoverClose,Menuwith its eleven parts (shortcuts asKbdcaps, checkbox and radio items, group labels, separators, submenus), andToastProviderwithuseToast(a slab pill, one at a time with three waiting, 5.2 s with a drain bar that holds while the region is hovered, focused or the window is away). Read the whole entry