Component
LiveRegion
A status region that speaks changes to screen readers without moving focus.
import { LiveRegion } from '@loidolt/theme-svelte';
Example
Saved 0 times. Screen readers hear each save, even when the text repeats.
Notes
- Mount it once and change
message. A region inserted together with its text is silent in most screen readers. - Pair it with
createAnnouncer(), which clears the region between messages so a repeated message is still announced, and empties it again afterclearAfterso no stale text lingers. politeness="assertive"interrupts the user — keep it for errors that need immediate attention.
Props
Generated from the component source, so it cannot drift from the implementation.
| Prop | Type | Default | Notes |
|---|---|---|---|
atomic | boolean | true | Read the whole region on every change, not only the changed part. |
children | Snippet | — | Rendered after message, for richer content. |
class | string | — | |
message | string | '' | Text to announce. Changing it is what triggers speech. |
politeness | Politeness | 'polite' | 'polite' waits for a pause (role="status"); 'assertive' interrupts (role="alert"). |
ref bindable | HTMLDivElement | null | null | |
visuallyHidden | boolean | true | Keep the region off-screen. Set false to also show the message visually. |
Plus the attributes of HTMLAttributes<HTMLDivElement>, forwarded to the root element.