Course contentsShow
← Web Development
Lesson 1119 of 2,98220. Screen Readers and Assistive TechnologyFree lesson

Toast Notification Patterns

Building accessible toast notifications that announce properly without disrupting navigation or focus.

Toast Notification Patterns

You'll learn how to build toast notifications that announce changes to screen reader users without disrupting their current focus or navigation flow.

What Are Toast Notifications?

Toast notifications are those brief messages that pop up temporarily to inform users of success, warnings, or updates—like "Message sent!" or "Item added to cart." For sighted users, they appear visually for a few seconds then disappear. For screen reader users, these must announce audibly without hijacking focus from whatever they're currently doing.

The Accessible Toast Pattern

The key is combining live regions (which you learned about) with careful focus management to create announcements that don't interrupt:

<div role="status" aria-live="polite" aria-atomic="true" class="toast-container">
  <!-- Toast messages get inserted here dynamically -->
</div>

Use role="status" (which implies aria-live="polite") for non-urgent toasts. The screen reader will announce them during the next natural pause, not immediately.

For urgent warnings, use role="alert" instead, which acts like aria-live="assertive".

Critical Pattern Rules

Don't move focus to the toast itself. The user might be typing in a form or navigating content—yanking focus away creates a jarring, disorienting experience.

Use aria-atomic="true" so the entire message announces, not just changed text fragments.

Add timing delays before removing toasts from the DOM—give screen readers time to announce before the element disappears (typically 150-200ms minimum after visual dismissal).

Example Pattern

The toast container stays in the DOM permanently but empty. When you need to show a toast, inject the message text. The live region announces it automatically without focus movement.

Key Takeaway: Accessible toasts use live regions (status or alert roles) to announce messages while keeping focus exactly where the user left it—never steal focus to temporary notifications.