Overview
Toast notifications slide in from a screen edge, hold for a configurable timeout, then dismiss themselves. The stack caps at a small number (3 in this pattern) so the surface never accumulates an unread pile. Each toast lives in an aria-live="polite" region so screen readers announce new toasts without interrupting active focus.
When to use it
Reach for toasts on success confirmations, transient errors, background-task progress updates — ephemeral status that the user does not need to act on. Skip toasts for anything that requires user action (use a modal instead) and for critical errors that must be acknowledged. Skip them on screens where the user is already focused on something time-sensitive — the slide-in becomes a peripheral distraction.
How it works
A single aria-live container is fixed to the viewport corner (typically bottom-right on desktop, top-center on mobile). New toasts are appended as children; CSS sibling selectors plus transform: translateY() shift older toasts upward by a fixed offset per neighbor. The enter animation is a single @keyframes rule that slides translateX from off-screen to zero with an ease-out curve, and the exit animation flips it. A timeout of 4–6 seconds adds the .is-dismissing class; the matching exit keyframe runs and animationend removes the DOM node. Cap the live region at three children — pop the oldest when a fourth arrives.
Production gotchas
Multiple toasts spawned in the same tick will trigger only the first announcement on most screen readers because aria-live="polite" coalesces rapid DOM mutations. Queue toasts behind a ~250ms gap if all need to be heard. Mobile Safari clips fixed elements that sit above the soft keyboard — offset the toast container by the keyboard inset (use visualViewport.height) or anchor toasts to the top on mobile. Animating height on stack shift causes layout thrash; use transform: translateY() instead so the compositor handles the upward shuffle.
Accessibility
Use aria-live="polite" for ordinary confirmations and aria-live="assertive" (or role="alert") only for errors that cannot wait. Dismiss-on-click should not be the only dismiss path — keyboard users need an explicit close button focusable inside the toast. Under prefers-reduced-motion: reduce swap the slide for a 100ms opacity fade so screen-reader announcements still align with the visual appearance.
References
Implementation depth
Toast stacks need ordering rules before motion rules. Decide where new notifications enter, how older ones compress, and which message owns focus or live-region priority before tuning translateY or scale.
Animation should never hide critical status. Errors and destructive confirmations may need persistent placement or explicit dismissal, while reduced motion should snap the stack into readable order.