Feedback
Toast
Notification toast
Demo
Loading demo…
A short message that pops up over the interface and goes away on its own. It confirms an action or flags a minor issue without interrupting what people are doing.
Story
Did you know
The name comes from the toaster: the message pops up from the edge of the screen like a slice of toast. Google renamed it "snackbar" in Material Design in 2014 and added an action button.
Timeline
- 2008Android 1.0 ships a
ToastAPI. - 2014Material Design introduces the Snackbar, with an action.
- 2023The Sonner library makes stacked toasts popular in the React ecosystem.
Vocabulary
Names
- FR
- Notification toast, message éphémère, notification temporaire
- EN
- Toast, snackbar, toast notification, flash message, notification
Common uses
- Confirming an action: "Link copied"
- Undoing an action just taken
- Reporting a non-blocking network error
Often paired with
The components it usually sits with, by page type, in reading order.
Blog post
See the mock-upProduct page
See the mock-upCode
<button id="save">Save</button>
<!-- The live region must exist before any message is injected -->
<div id="toasts" role="status" aria-live="polite"></div>
<script>
const region = document.querySelector('#toasts')
function toast(message, ms = 5000) {
const el = document.createElement('div')
el.className = 'toast'
el.textContent = message
region.append(el)
setTimeout(() => el.remove(), ms)
}
document.querySelector('#save').addEventListener('click', () => toast('Changes saved'))
</script>Good to know
- Mount a single toast container at the app root and expose a
toast()function (store, context or service). Components shouldn't each render their own. - With
popover="manual", the container moves to the top layer: above the rest of the page, with noz-indexbattles. - Cap the stack at about 3 toasts and merge identical messages: ten "Saved" in a row is just noise.
- An error that needs action has no place in a toast that fades away. Put it in the page, next to its cause.
Accessibility
Must have
- Messages go into a
role="status"region (polite). Keeprole="alert"for urgent errors: it interrupts the screen reader. - Never move focus to the toast. It should inform without breaking the current task.
Often forgotten
- The
aria-liveregion must exist before the message is injected. Created together with the text, it won't be announced. - Timing: at least 5 seconds, longer for long text, paused on hover and on focus. A toast with an action (Undo) needs an adjustable delay or another way to act (WCAG 2.2.1).
- The Undo button must stay reachable by keyboard before the toast disappears, for example through a shortcut.
Nice to have
- Respect
prefers-reduced-motion: fade in rather than slide in. - Put the stack in a named region (
<section aria-label="Notifications">) so it is easy to find.