Guide
Accessible toast notifications
An accessible toast is announced by screen readers without moving focus, can be reached and dismissed from the keyboard, stays long enough to read and use, and respects reduced motion. Boing handles all of this with its default <Toaster />; this page explains each part.
How do screen readers hear a toast?
Through live regions: elements the screen reader watches and reads out when their text changes. The region has to exist on the page before the message goes into it, otherwise many screen readers miss the first announcement.
- Boing renders two hidden regions as soon as the Toaster mounts: a
role="status"region (polite) and arole="alert"region (assertive). - Errors go to the alert region, which interrupts what the screen reader is saying. Everything else goes to the polite status region, which waits for a pause.
- The visible toast has no live role of its own, so each message is read once, not twice.
- The same message sent twice in a row is still read again.
- Progress bar updates stay silent, so a fast upload does not flood the user with announcements.
This is what WCAG 4.1.3 (Status Messages) asks for: status updates announced without taking focus.
Do not steal focus; make the toast reachable
Showing a toast never moves focus, so the user keeps typing or tabbing where they were. A toast with a button still has to be reachable, though, and tabbing through the whole page to find it is not reasonable.
| Key | What it does |
|---|---|
| Alt+T | Moves focus to the toast’s first button, or to the toast itself if it has none. |
| Esc | Dismisses toasts, unless focus is in a dialog, menu, listbox or form field, where Escape belongs to that control. |
| Tab | Moves between the toast’s buttons. They are in the tab order only while the toast is open. |
Toasts that stay on screen get a close button labelled “Dismiss notification” unless they already have a secondary button. Buttons have a hit area at least 44px tall.
Give people enough time
A toast that disappears on a timer is a time limit. WCAG 2.2.1 (Timing Adjustable) asks that users can turn such limits off, adjust or extend them, and 2.2.2 (Pause, Stop, Hide) covers content that changes on its own. Boing’s defaults are built around that:
- Errors and toasts with a button have no timer. They stay until handled.
- Hovering a toast, or focusing it with the keyboard, pauses every timer. Moving away resumes it.
- Short confirmations close after 5 seconds. They repeat what is already visible on the page, so missing one costs nothing.
If you give an undo toast a duration, keep it generous. The undo guide has more on this.
Respect reduced motion
When the system asks for reduced motion, toasts skip the spring and the squash, appear at their final size and fade in over 0.2 seconds. Icon animations, the loading spinner and the countdown line are off. Nothing needs configuring. On right-to-left pages the reveal direction and countdown line are mirrored.
Translate the labels
Boing has two built-in strings: the name of the toast region (“Notifications”) and of the close button (“Dismiss notification”). Translate them with the labels prop:
The text of each toast is yours, so it is translated however the rest of your app is. See accessibility in the docs for the full list.
Frequently asked questions
Should a toast use role alert or role status?
Use status for most messages so the screen reader finishes what it is saying first. Keep alert for errors that need attention now. Boing routes them this way automatically.
Should a toast take keyboard focus when it appears?
No. Moving focus interrupts whatever the user was doing. Let a live region read it out, and give keyboard users a shortcut to jump in when they choose (Boing uses Alt+T).
Is an auto-dismissing toast an accessibility problem?
It can be when the toast holds an action or information found nowhere else. Keep those open until dismissed, and pause timers on hover and focus.
How do I translate the close button label?
Pass labels={{ region, dismiss }} to the Toaster, or call toast.configure({ labels }).
Related guides
- Undo toastAct first, offer undo.
- Toast notification UXWhen a toast helps and when it gets in the way.
- React toast animationSprings, morphing in place and reduced motion.
- Boing docsSetup, options, styling, sound and accessibility.