Announcer
Headless Announcer; covers ARIA live regions, coalesced announcement queues.
| Package | @vizejs/ui/announcer |
| Maturity | stable |
| Own the source | vize lib pull announcer |
| Requires | context, live-region |
| Aliases | announcement queue, status announcer, busy announcements |
| Covers | ARIA live regions, coalesced announcement queues |
Minimal setup
Use a Vue 3.5+ project with Vue SFC compilation configured (see Vite+ integration).
vp install @vizejs/ui
Add the public import below to <script setup lang="ts">. Components provide behavior without styles; the preview uses optional Paper styles.
import { AnnouncerProvider } from "@vizejs/ui/announcer";
Or copy the source into your project with vize lib pull announcer (see Source Distribution).
Try it
This is the basic example maintained with the component source, using the public package imports. The preview adds the optional Paper styles.
Open the interactive example · Styling these components
Copy the example
<!-- Provider that owns the live regions and announces cart updates from its slot. -->
<script setup lang="ts">
import { ref } from "vue";
import { AnnouncerProvider, type AnnouncerController } from "@vizejs/ui/announcer";
const count = ref(0);
function addItem(announcer: AnnouncerController): void {
count.value += 1;
announcer.announce(`Added to cart. ${count.value} items in cart.`, { key: "cart" });
}
function emptyCart(announcer: AnnouncerController): void {
count.value = 0;
announcer.announce("Cart emptied.", { politeness: "assertive" });
}
</script>
<template>
<AnnouncerProvider v-slot="{ announcer }">
<p>Items in cart: {{ count }}</p>
<button type="button" @click="() => addItem(announcer)">Add to cart</button>
<button type="button" @click="() => emptyCart(announcer)">Empty cart</button>
</AnnouncerProvider>
</template>
API
AnnouncerProvider
Source: src/families/accessibility/announcer/announcer-provider.vue
Props
| Prop | Type | Default | Description |
|---|---|---|---|
politeness |
AnnouncerPoliteness |
"polite" |
Default urgency for announcements that do not name one. |
atomic |
boolean |
true |
Whether assistive technology should present a whole channel on each update. |
Slots
| Slot | Slot props | Description |
|---|---|---|
default |
{ readonly announcer: AnnouncerController } |
Subtree served by this announcer. Receives the owning controller. |
Exposed
| Member | Type | Description |
|---|---|---|
announcer |
— | |
isOwner |
— | |
announce |
— | |
clear |
— |
Behavior
Normative state × input → outcome table for announcer-provider.vue and the
announcement queue (@vizejs/ui/announcer). Every row is proven by the named
test in src/families/accessibility/announcer/announcer.test.ts or
src/families/accessibility/announcer/announcer-ssr.test.ts; compile-only
assertions live in src/families/accessibility/announcer/announcer.types.test-d.ts.
| # | State | Input | Outcome | Proven by |
|---|---|---|---|---|
| N1 | idle | render provider | one empty polite and one empty assertive region | renders one polite and one assertive region |
| N2 | idle | announce sequence |
messages flush in order, one channel tick each | queues announcements sequentially |
| N3 | queued | assertive announce |
assertive text precedes queued polite text | flushes assertive announcements before polite ones |
| N4 | queued | identical announce |
duplicate pending text on a channel is dropped | deduplicates identical pending announcements |
| N5 | queued | keyed announce |
a pending message with the same key is replaced | coalesces keyed announcements |
| N6 | busy | update then end |
only the latest progress and the outcome are heard | announces busy work without flooding |
| N7 | busy ended | update |
throws a stable busy diagnostic | rejects progress after a busy announcement ends |
| N8 | nested | render provider in provider | inner provider delegates; no duplicate regions | nested providers reuse the owner's regions |
| N9 | nested | descendant announce |
text surfaces in the owning provider's region | nested providers reuse the owner's regions |
| N10 | queued | clear |
pending queue drops and both channels empty | clears pending announcements and both channels |
| N11 | any | dispose, then any call |
throws a stable disposed diagnostic | rejects use after dispose |
| N12 | no scope | useAnnouncer |
throws a stable setup diagnostic | rejects composable use outside an effect scope |
| N13 | SSR | render nested + setup announce | byte-identical markup, single empty region pair | SSR test |
| N14 | public types | invalid politeness | compilation rejects misuse | src/families/accessibility/announcer/announcer.types.test-d.ts |