DocsFeedback & undo
Get started

Search Subtly documentation

Search by a task, helper name or framework.

Feedback & undo

liveAnnouncer()

Read updates aloud to screen readers.

Try the example

Add a sample item to the basket. The count updates visually and the same useful update is announced politely to a screen reader without moving your focus.

Sample productEveryday notebook

Illustrative basket. No purchase is made.

Basket 0 items
Actual npm package · local demonstration

Add it to your project

  1. Copy the HTML. Place the markup inside the component where this behavior belongs. The preview’s visual classes are website styles; use your own design system.
  2. Connect the behavior. Copy the JavaScript tab and call its exported mount(element) after your component’s elements exist. Replace simulated delays and data operations with your own application code.
  3. Clean up. Call the returned cleanup when the component unmounts. It aborts the example’s listeners and releases the helper’s timers, observers or state.

API and lifecycle

Create a persistent empty live region before updates occur. announce(message) writes a text update after a short delay. The default priority is polite; include the visually hidden CSS so the region remains accessible.

Interface
priority, parent; announce/destroy; include CSS
Lifecycle
Reuse the instance for related updates. destroy() cancels the pending announcement and removes the live-region element.

Accessibility and safety

Implementation notes

Initialize after the DOM is available. Keep native controls and keyboard interactions intact; release listeners and timers on unmount.

Use assertive only for urgent interruptions. Avoid duplicate announcements of visible focused errors, and do not move focus to routine status updates.

What to check

Use a screen reader to check one useful announcement per update. Confirm routine updates do not interrupt typing or move keyboard focus.