One line, and screen readers hear “Saved”.
announce('Saved') speaks to screen-reader users from anywhere in your app, with no provider and nothing to mount. Add a signal-driven live region, a skip link, visually hidden labels and ARIA ids: the pieces single-page apps usually leave out.
bun add @pyreon/a11y - setup
- noneThe live regions create themselves on the first call.
- server
- SSR-safeannounce() is a no-op on the server; components render plain markup.
- route changes
- announced by defaultBuilt into the root
<RouterView>; customise with<RouteAnnouncer>. - dependencies
- noneOnly Pyreon itself. The router integration is a separate entry.
The accessibility gaps SPAs leave open, closed.
Say what just happened
"Saved", "3 results", "Connection lost".
announce()writes into a polite or assertive live region it created on first use. Two messages in the same moment are joined, not overwritten, and saying "Saved" twice is heard twice.Status that announces itself
<LiveRegion>{() => status()}</LiveRegion>speaks every change of a signal. No effect, no call. It renders on the server, so the region exists before the first update after hydration.Navigation you can hear
In a single-page app the page never reloads, so a screen reader stays silent. The root
<RouterView>announces each new page by default;<RouteAnnouncer>lets you choose the wording.The same call on the phonenext release
Compiled for iOS (native targets are experimental),
announce()becomes a VoiceOver announcement; on Android the compiler hosts polite and assertive live regions for TalkBack. Politeness carries over on both (iOS 17 and later).
Accessible feedback without the plumbing.
A live region you mount, clear and refill on a timer, or a repeat goes unheard.
<div aria-live="polite" class="sr-only" id="status"></div>
function save() {
// …
const el = document.getElementById('status')!
el.textContent = ''
setTimeout(() => {
el.textContent = 'Settings saved'
}, 100)
}One call, from any handler. The regions, the clearing and the repeat handling are done for you.
import { announce } from '@pyreon/a11y'
announce('Settings saved')
announce('Connection lost', { politeness: 'assertive' })
announce('Copied', { clearAfter: 1000 })Hear what a screen reader hears.
Use the app on the left. The panel on the right shows what announce() sends to screen readers: the text sighted users never see. Tab into the box and the skip link appears first.
Tab into this box: a skip link appears first.
Price: $129
Small primitives, big difference.
- announce() polite by default, assertive for errors and urgent changes
- Queued, not lost: messages announced together are joined into one, never overwritten
- Repeats re-announced: the region is cleared before each write, so "Saved" twice is heard twice
- clearAfter empties the region so stale text is not read again later
<LiveRegion>driven by a signal, withvisiblefor status text everyone should see<VisuallyHidden>labels and headings for assistive tech, kept in the accessibility tree<SkipLink>moves scroll and keyboard focus past the navigation (WCAG 2.4.1)- createA11yId unique ids for
aria-labelledby,aria-describedbyandfor <RouteAnnouncer>anduseRouteAnnouncercustom route-change wording, with a dev warning if two announcers run at once- Router-free main entry
@pyreon/a11y/routeris a separate import, so announce() never pulls in the router
Things to build with it.
A visible result count that is also announced every time it changes. <LiveRegion> tracks the computed, so there is no announce call to remember.
import { computed, signal } from '@pyreon/reactivity'
import { For } from '@pyreon/core'
import { LiveRegion, VisuallyHidden } from '@pyreon/a11y'
const ALL = ['Signals', 'Router', 'Hooks', 'Forms', 'Charts']
export function Search() {
const query = signal('')
const results = computed(() => ALL.filter((x) => x.toLowerCase().includes(query().toLowerCase())))
return (
<div>
<label>
<VisuallyHidden>Search packages</VisuallyHidden>
<input type="search" onInput={(e) => query.set(e.currentTarget.value)} />
</label>
<LiveRegion visible>{() => `${results().length} results`}</LiveRegion>
<ul>
<For each={results()} by={(r) => r}>
{(r) => <li>{r}</li>}
</For>
</ul>
</div>
)
}The hint is linked to the input with a generated id, the input flags itself invalid, and the outcome is spoken: assertive for the error, polite for success.
import { signal } from '@pyreon/reactivity'
import { announce, createA11yId } from '@pyreon/a11y'
export function PasswordField() {
const hintId = createA11yId('hint')
const value = signal('')
const invalid = signal(false)
const submit = (e: SubmitEvent) => {
e.preventDefault()
const bad = value().length < 8
invalid.set(bad)
announce(bad ? 'Password needs at least 8 characters' : 'Account created', {
politeness: bad ? 'assertive' : 'polite',
})
}
return (
<form onSubmit={submit}>
<label for="pw">Password</label>
<input
id="pw"
type="password"
aria-describedby={hintId}
aria-invalid={() => invalid()}
onInput={(e) => value.set(e.currentTarget.value)}
/>
<p id={hintId}>At least 8 characters.</p>
<button type="submit">Create account</button>
</form>
)
}A skip link first in the tab order, and route changes announced as "Billing page". Turn the router's built-in announcer off when you use your own, or every page is announced twice.
import { createRouter, RouterProvider, RouterView } from '@pyreon/router'
import { RouteAnnouncer } from '@pyreon/a11y/router'
import { SkipLink } from '@pyreon/a11y'
const Home = () => <h1>Home</h1>
const Billing = () => <h1>Billing</h1>
const router = createRouter({
routes: [
{ path: '/', component: Home, meta: { title: 'Home' } },
{ path: '/billing', component: Billing, meta: { title: 'Billing' } },
],
})
export function App() {
return (
<RouterProvider router={router}>
<SkipLink href="#main">Skip to content</SkipLink>
<RouteAnnouncer format={(to) => `${to.meta.title ?? to.path} page`} />
<main id="main">
<RouterView announceRouteChanges={false} />
</main>
</RouterProvider>
)
}8 exports for your app, two entry points.
Every export has a reference page with its signature, an example and the mistakes people make with it.
- announce
- clearAnnouncements
- LiveRegion
- VisuallyHidden
- SkipLink
- createA11yId
- RouteAnnouncer
- useRouteAnnouncer
Good to know before you start.
Keep assertive for what is urgent
An assertive message cuts off whatever the user was hearing. Use it for errors and lost connections; leave status updates polite.
Announcements happen in the browser
announce() does nothing during SSR, by design. Call it from handlers and effects, not while rendering.
One route announcer at a time
<RouterView> already announces navigation. If you add <RouteAnnouncer>, switch the built-in one off; a dev warning tells you when both are running.
clearAfter stays on the web
In native builds announce() keeps its politeness, but clearAfter is ignored on iOS and Android.
What people ask first.
Do I need to mount a provider or an announcer component?
No. The first announce() call creates two visually hidden live regions on document.body, one polite (role="status") and one assertive (role="alert"), and reuses them for the life of the page.
Why does a message arrive about 100 ms after the call?
Screen readers often ignore a live region that is created and filled in the same moment, and rapid writes overwrite each other. The short wait lets the region exist first and lets messages sent together be joined into one announcement.
announce() or <LiveRegion>?
announce() for one-off events with no place in the layout, like "Copied". <LiveRegion> when the status already lives somewhere on the page, like a result count or a "Saving…" line.
Do I need <RouteAnnouncer> with the Pyreon router?
Usually not: the root <RouterView> announces route changes on its own. Use <RouteAnnouncer> for custom wording or politeness, and pass announceRouteChanges={false} to <RouterView> when you do.
Does this replace an accessibility audit?
No. These are building blocks. For checks, Atlas runs axe-core on each generated component scenario, and @pyreon/lint has opt-in rules such as pyreon/require-img-alt and pyreon/no-positive-tabindex.
Built to be used together.
Router
Route changes announced by default.
Forms
Labels, errors and aria-describedby wired for you.
Atlas
axe-core checks on every component scenario.
Motion
Animations that respect reduced motion.
Your app already looks good. Now let it say so.
bun add @pyreon/a11y