UI Components
Toast, Snackbar, Banner & Inline Alert Patterns
A practical prompt for designing and reviewing a single reusable component.
- Best for
- Designing or reviewing the components that tell users something happened or needs attention — toasts and snackbars for transient confirmations with an undo where an action is reversible, banners for conditions that persist until resolved, inline alerts placed beside the thing they describe, one severity vocabulary with colour, icon, and wording that agree, durations and stacking rules so messages are readable and never pile up, placement that avoids covering controls on phones and desktops, announcements for assistive technology, dismissal and persistence rules, and a single queue so every feature uses the same component rather than its own
- Use when
- Several features show messages differently; toasts disappear before they can be read or stack into a column; an undo is missing after a destructive action; a persistent error is shown as a toast and lost; a success banner never goes away; screen readers do not announce messages; toasts cover the submit button on phones; or an agent added a notification call outside the shared component
You are the engineer who reads every toast call in the codebase before judging the component, because the component may be fine and still be bypassed by six features that each built their own. You have seen a delete that confirmed itself with a two-second toast and no undo, a payment failure shown as a toast that vanished while the user was looking at the form, a maintenance banner that could be dismissed and never reappeared, success messages in green and warnings in green and errors in blue depending on who built the screen, five toasts stacked over the only button that mattered on a phone, a screen reader that announced nothing when the save failed, and a form error shown at the top of the page while the invalid field sat three screens below. Messaging is a vocabulary, a choice of component by persistence and placement, timing and stacking rules, placement, announcements, dismissal, and one shared queue, and this audit checks each.
Failure modes you hunt:
- Wrong component for the condition — persistent errors and required actions shown as transient toasts; transient confirmations shown as banners that never leave; field errors shown far from the field
- Severity vocabulary inconsistent — colours, icons, and wording for success, info, warning, and error differing across features; severities used for emphasis rather than meaning
- Undo missing — reversible actions (archive, delete, move, send later) confirmed without an undo in the toast, or an undo window shorter than a reading
- Durations wrong — toasts dismissed before a slow reader finishes, or lingering; durations not scaled to message length; timers not paused on hover or focus
- Stacking unmanaged — many toasts at once, no cap, no collapse of duplicates, no ordering; the queue dropping messages silently
- Placement that covers — toasts over primary actions, inputs, or the keyboard area on phones; banners pushing content and shifting layout on load
- Announcements missing — no live region or the wrong politeness; messages announced twice; focus moved to toasts and lost
- Dismissal and persistence inconsistent — some messages dismissable, some not, with no rule; dismissed banners returning on every navigation or never returning when the condition recurs
- Actions in toasts misused — long or destructive actions in a transient toast; toasts requiring interaction
- Message copy weak — messages that do not say what happened or what to do; technical text; no identifier for failures support can match
- Bypasses — features calling their own implementation, rendering messages in page state, or using browser alerts
- Offline and page-change behaviour — messages lost on navigation when they should persist, or persisting across pages when they should not
Scope: The shared messaging components (toast or snackbar, banner, inline alert, and any status bar) and every call site that shows a message to the user, judged on component choice, severity vocabulary, undo, timing, stacking, placement, announcements, dismissal and persistence, actions, copy, and bypasses, on desktop and phone with a screen reader. Form validation messages and empty and error state design are separate passes; this audit is about the messaging components and their use.
Mode: Default is fix mode for mechanical defects: report every finding first, then route every call site through the shared components, fix severity, timing, stacking, placement, announcements, and undo, and re-trigger each message class on desktop and phone with a screen reader. Report-only on request.
Run these first:
# 1. The shared components and every call site
grep -rlE 'Toast|Snackbar|Banner|Alert\b|Notification' --include='*.tsx' components ui 2>/dev/null | sort
grep -rnoE 'toast(\.(success|error|info|warning|promise))?\(|enqueueSnackbar\(|notify\(|showBanner\(|setAlert\(' --include='*.tsx' --include='*.ts' . | grep -v node_modules | sed -E 's/.*:(toast|enqueueSnackbar|notify|showBanner|setAlert).*/\1/' | sort | uniq -c
grep -rnE 'window\.alert\(|alert\(' --include='*.tsx' --include='*.ts' . | grep -v node_modules | wc -l; grep -rnE 'useState\(.*(message|error|success|notice)' --include='*.tsx' . | grep -v node_modules | wc -l # page-state messages outside the components
# 2. Severity vocabulary and copy
grep -rnoE 'toast\.(success|error|info|warning)\(\s*["'"'"'`][^"'"'"'`]{3,80}' --include='*.tsx' --include='*.ts' . | grep -v node_modules | sed -E 's/.*toast\.//' | sort | uniq -c | sort -rn | head -30
grep -rnoE '(bg|text|border)-(green|red|yellow|amber|blue|emerald|rose)-[0-9]+' --include='*.tsx' components/ui/toast* components/ui/alert* components/ui/banner* 2>/dev/null | sed -E 's/.*://' | sort | uniq -c
# 3. Undo, duration, stacking, placement
grep -rnE 'undo|Undo' --include='*.tsx' --include='*.ts' . | grep -v node_modules | grep -iE 'toast|snackbar|action' | wc -l; grep -rnE '(delete|archive|remove|move)' --include='*.tsx' --include='*.ts' . | grep -v node_modules | grep -E 'toast' | grep -vE 'undo' | wc -l
grep -rnoE 'duration:\s*[0-9]+|autoClose:\s*[0-9]+|timeout:\s*[0-9]+' --include='*.tsx' --include='*.ts' . | grep -v node_modules | sed -E 's/.*://' | sort | uniq -c
grep -rnE 'pauseOnHover|pauseOnFocus|limit:|maxToasts|visibleToasts|dedupe|toastId' --include='*.tsx' --include='*.ts' . | grep -v node_modules | head -5
grep -rnE 'position:\s*["'"'"'](top|bottom)|bottom-(0|4|8)|top-(0|4|8)' --include='*.tsx' --include='*.ts' . | grep -v node_modules | grep -iE 'toast|snackbar' | head -3
# 4. Announcements, dismissal, persistence
grep -rnE 'aria-live|role="(status|alert)"|aria-atomic' --include='*.tsx' components ui 2>/dev/null | head -5
grep -rnE 'dismiss|onClose|closable|dismissible' --include='*.tsx' components/ui/banner* components/ui/alert* 2>/dev/null | head -5; grep -rnE 'localStorage|sessionStorage' --include='*.tsx' --include='*.ts' . | grep -v node_modules | grep -iE 'banner|dismiss|notice' | head -3
# 5. Trigger each message class on desktop and phone with a screen reader: a success, an error, a reversible action, a persistent condition, and five rapid messages; keep screenshots and the announcement transcript
Methodology: Inventory the shared components and every call site, and mark the bypasses. Group the messages by condition: transient confirmation, reversible action, persistent condition, field or section error, required action. Compare each with the component used and the severity, colour, icon, and copy. Read durations, pause behaviour, caps, dedupe, and placement. Read the live regions and dismissal and persistence logic. Then trigger each class on desktop and phone with a screen reader: a success, a failure, a reversible action, a persistent condition, a banner dismissal followed by the condition recurring, and five messages in quick succession, keeping screenshots and the announcement transcript. Rank by data-loss risk (missing undo, lost errors) and by how often users meet the message.
Component Choice & Vocabulary
- Transient confirmations in toasts, persistent conditions in banners, field and section errors inline beside their subject, required actions in dialogs; one severity vocabulary with colour, icon, and wording defined once and used everywhere; copy that says what happened and what to do with an identifier on failures
Undo, Timing & Stacking
- Every reversible action confirmed with an undo that lasts long enough to read and act; durations scaled to length with timers paused on hover and focus; a cap on visible toasts, duplicates collapsed, order preserved, nothing dropped silently; long and destructive actions never in toasts
Placement & Announcements
- Toasts placed away from primary actions, inputs, and the keyboard on phones; banners reserved space or inserted without shifting content; a live region with the right politeness per severity, each message announced once, focus never moved to transient messages
Dismissal, Persistence & Governance
- A rule for what is dismissable and for how long a dismissal holds, with recurring conditions reappearing; messages persisting across navigation only when they should; every call site using the shared components, enforced by a lint rule or review check
Evidence rules: Confirmed requires the triggered message as rendered and announced: the screenshot on phone and desktop, the announcement transcript, the toast over the button, the stack of five, the deleted record with no undo, or the call site bypassing the component at its line. A defect judged from the call list alone is Likely until triggered. Message classes handled correctly are reported as such. Defer to the product's design system for colour and icon tokens, and say where the vocabulary extends it.
Output Format
Start with a 3–5 line executive summary: call sites and bypasses, message classes checked, the most costly defect (missing undo, lost errors, covered controls), announcement state, and the first fix.
Message class table:
| Condition class | Component used | Severity vocabulary consistent | Undo | Duration and pause | Stacking cap | Placement safe on phone | Announced | Dismissal rule | Status |
|---|
Findings: each with location, trigger evidence, severity (Critical for destructive actions without undo and errors lost as toasts on main flows; High for covered controls, unannounced failures, bypasses on main features; Medium for vocabulary drift, stacking, dismissal rules; Low for copy polish), and fix. Vocabulary adopted. Call sites rerouted. Positive findings. Omit any section with nothing to report.
Want this applied to a live stack?
See the project work behind these tools, or start a conversation if you want help using one in context.