When to use it#
- Offer it on text people may prefer to hear: a long guidance page, a decision letter, a notice. It helps someone with dyslexia, low literacy or a cognitive disability, a reader using their second language, a visitor with low vision, or anyone who is tired or doing something else at the same time.
- It is not aimed at screen-reader users: they already have a better reader, and ReadAloud must never fight it. Offer it to everyone and never hide it from assistive technology (software that people with disabilities use, such as a screen reader).
- There are two ways to offer it. The panel sits beside one article, with full-word buttons (
Listen,Previous sentence,Next sentence,Stop): add one wherever you have a long text. TheReadAloud.Barsits once in your page layout and reads whichever page the visitor is on, with Previous, Next, Stop and Settings as icons and the word kept on Play: choose it for listening everywhere without adding anything to each page. Both share one Settings menu for speed and voice. - Put the panel directly before the text it reads, in the normal flow of the page — never floating, never in a menu. The bar is different: it sits at the top of every page, above the site’s own navigation, and only becomes sticky while it is reading, so it never covers anything before a visitor has pressed anything. Neither player starts by itself.
- Listen reads the whole text, or only the text the reader has selected (select with Shift and the arrow keys, then press Listen). Pause and Stop control it, and Previous and Next move one sentence at a time.
- Pressing Listen sends that page's text to Kvirn's voice service, which turns it into speech. The service is Kvirn's own, hosted in the EU, sets no cookies and, by default, does not save the text or the audio — unless you opt in with
store: true, which is only for public page text, never for anything that could contain an identity number. The player's recipient sentence changes its own wording to match. Nothing is sent before the reader presses Listen. Each player already tells the visitor who receives the text — theNotepart in the panel, or the Settings menu in the bar — but linking your own explanation of how listening works, and naming the service in your privacy notice, is still your own job. - Today the service has voices for Swedish, Norwegian (Bokmål) and English only. A page in Finnish or Norwegian Nynorsk gets no player at all, not even for a moment: the check happens before anything is shown, so nothing flashes on screen.
- The voice always follows the text's own declared language, never the page's interface language. A Finnish municipality can run a Finnish interface around Swedish-language content, and it still reads in Swedish.
- It is not for announcing a change in the page. Use the Announcer for that.
Example#
Press Listen to hear the article. Previous and Next move one sentence; Speed changes how fast it is read, without a new request. If the voice service isn’t running (it reads the address from an environment variable, and uses a local address during development), Status says it can’t be reached right now, rather than the button doing nothing.
Listening sends this text to Kvirn’s voice service to make the audio. The text and the audio are not saved. How listening works
Applying for a building permit
You apply for a building permit in the municipality where the building will stand. Start with the property designation and a short description of the work. Attach a site plan.
The case officer reviews the application within ten weeks. If something is missing you are told what, and the time stops until you reply.
import { kvirnSpeechEngine } from '@kvirn-ui/core'
import { Heading } from '@kvirn-ui/react'
import { ReadAloud } from '@kvirn-ui/read-aloud'
import { useRef } from 'react'
import { voiceServiceUrl } from '../../lib/voice-service-url.ts'
import { useReadAloudTexts } from './texts.ts'
// Made once, outside the component, so the player gets the same engine on every render. `name` is
// the recipient the Note part tells the reader about, so it is passed explicitly rather than left
// to default to the URL's host.
const voiceServiceName = 'Kvirn’s voice service'
const engine = kvirnSpeechEngine({ url: voiceServiceUrl, name: voiceServiceName })
export function Player() {
const { texts } = useReadAloudTexts()
const articleRef = useRef<HTMLElement>(null)
return (
<>
<ReadAloud.Root contentRef={articleRef} engine={engine} name={voiceServiceName}>
<ReadAloud.Progress />
<ReadAloud.Play />
<ReadAloud.Transport>
<ReadAloud.Previous />
<ReadAloud.Next />
</ReadAloud.Transport>
<ReadAloud.Stop />
<ReadAloud.Rate />
<ReadAloud.Status />
<ReadAloud.Note howItWorksHref="/privacy#voice" />
</ReadAloud.Root>
<article ref={articleRef}>
<Heading as="h4">{texts.title}</Heading>
<p>{texts.firstParagraph}</p>
<p>{texts.secondParagraph}</p>
</article>
</>
)
}Use cases#
A quiet panel that only shows controls once you start listening
At rest, show only Listen. A row of controls that do nothing yet — a disabled Previous and Next, an empty progress bar — can look broken. Wrap the rest in ReadAloud.WhenStarted: it appears once you press Listen, in the same place, so the button under your finger does not move, and it never collapses back once reading has started.
Listening sends this text to Kvirn’s voice service to make the audio. The text and the audio are not saved. How listening works
How winter parking rules work
From 1 December to 31 March, parking on odd dates is allowed on the odd side of the street, and on even dates on the even side, so snow ploughs can get through. Move your car by 8 a.m.
import { kvirnSpeechEngine } from '@kvirn-ui/core'
import { Heading } from '@kvirn-ui/react'
import { ReadAloud } from '@kvirn-ui/read-aloud'
import { useRef } from 'react'
import { voiceServiceUrl } from '../../lib/voice-service-url.ts'
import { useReadAloudTexts } from './texts.ts'
const voiceServiceName = 'Kvirn’s voice service'
const engine = kvirnSpeechEngine({ url: voiceServiceUrl, name: voiceServiceName })
export function IdlePanel() {
const { texts } = useReadAloudTexts()
const articleRef = useRef<HTMLElement>(null)
return (
<>
<ReadAloud.Root contentRef={articleRef} engine={engine} name={voiceServiceName}>
<ReadAloud.Play />
<ReadAloud.WhenStarted>
<ReadAloud.Transport>
<ReadAloud.Previous />
<ReadAloud.Next />
</ReadAloud.Transport>
<ReadAloud.Stop />
<ReadAloud.Settings />
<ReadAloud.Status />
</ReadAloud.WhenStarted>
<ReadAloud.Note howItWorksHref="/privacy#voice" />
</ReadAloud.Root>
<article ref={articleRef}>
<Heading as="h4">{texts.idlePanel.title}</Heading>
<p>{texts.idlePanel.paragraph}</p>
</article>
</>
)
}A listening bar for the whole site
Add ReadAloud.Bar once in your page layout, with a scope selector, instead of placing a player on every page. It reads whichever part of the page matches that selector, sits above the site’s own navigation, and only becomes sticky while it is reading.
import { kvirnSpeechEngine } from '@kvirn-ui/core'
import { Heading, Link, Navigation } from '@kvirn-ui/react'
import { ReadAloud } from '@kvirn-ui/read-aloud'
import { voiceServiceUrl } from '../../lib/voice-service-url.ts'
import { useReadAloudTexts } from './texts.ts'
// Built once, outside the component: a site-wide Bar is mounted once in a real layout, so its
// engine is built once too.
const voiceServiceName = 'Kvirn’s voice service'
const engine = kvirnSpeechEngine({ url: voiceServiceUrl, name: voiceServiceName })
export function BarLayout() {
const { texts } = useReadAloudTexts()
return (
<div className="kv-read-aloud-bar-demo">
{/* No contentRef: the Bar reads whatever matches `scope`, so one include in a layout works
* for every page without per-article wiring. */}
<ReadAloud.Root
engine={engine}
name={voiceServiceName}
scope=".kv-read-aloud-bar-demo-article"
>
<ReadAloud.Bar howItWorksHref="/privacy#voice" />
</ReadAloud.Root>
<Navigation.Root label={texts.barDemo.navLabel} className="kv-navigation--horizontal">
<Navigation.List>
<Navigation.Item>
<Link.Root href="#home">{texts.barDemo.navHome}</Link.Root>
</Navigation.Item>
<Navigation.Item>
<Link.Root href="#services">{texts.barDemo.navServices}</Link.Root>
</Navigation.Item>
<Navigation.Item>
<Link.Root href="#contact">{texts.barDemo.navContact}</Link.Root>
</Navigation.Item>
</Navigation.List>
</Navigation.Root>
<article className="kv-read-aloud-bar-demo-article">
<Heading as="h4">{texts.barDemo.title}</Heading>
<p>{texts.barDemo.paragraph}</p>
</article>
</div>
)
}Props in this example:
scopeon ReadAloud.Root
Marking which part of a CMS page to read
A content management system renders its own HTML, where React cannot write a comment. Wrap the part a resident should hear in <!-- KV:READ-ALOUD:START --> and <!-- KV:READ-ALOUD:STOP -->, so the player skips things like a related-links box around it.
Listening sends this text to Kvirn’s voice service to make the audio. The text and the audio are not saved. How listening works
Your case decision
The municipality has decided to grant your application for a disabled parking permit.
The permit is valid for three years and is sent to your registered address.
import { kvirnSpeechEngine } from '@kvirn-ui/core'
import { ReadAloud } from '@kvirn-ui/read-aloud'
import { useRef } from 'react'
import { voiceServiceUrl } from '../../lib/voice-service-url.ts'
import { useReadAloudTexts } from './texts.ts'
const voiceServiceName = 'Kvirn’s voice service'
const engine = kvirnSpeechEngine({ url: voiceServiceUrl, name: voiceServiceName })
export function CmsMarkers() {
const { texts } = useReadAloudTexts()
const containerRef = useRef<HTMLDivElement>(null)
// A content management system writes plain HTML, so it can place the
// KV:READ-ALOUD:START/STOP comments its own template engine cannot reach from React. Built
// from this example's own texts, so the fixture text still lives in one place.
const html = `
<aside class="kv-read-aloud-cms-related">
<h4>${texts.cms.relatedHeading}</h4>
<p>${texts.cms.relatedText}</p>
</aside>
<!-- KV:READ-ALOUD:START -->
<article>
<h4>${texts.cms.title}</h4>
<p>${texts.cms.paragraph1}</p>
<p>${texts.cms.paragraph2}</p>
</article>
<!-- KV:READ-ALOUD:STOP -->
`
return (
<>
<ReadAloud.Root contentRef={containerRef} engine={engine} name={voiceServiceName}>
<ReadAloud.Play />
<ReadAloud.Status />
<ReadAloud.Note howItWorksHref="/privacy#voice" />
</ReadAloud.Root>
{/* eslint-disable-next-line react/no-danger -- stands in for a CMS's own server-rendered HTML, markers included */}
<div ref={containerRef} dangerouslySetInnerHTML={{ __html: html }} />
</>
)
}Props in this example:
contentRefon ReadAloud.Root
Information: Did you know?
Most HTML minifiers strip comments by default. Keep comments on in production, or the markers disappear and the player reads everything instead.
Content in a different language from the interface
The voice follows the text’s own declared language, never the page’s interface language. Here the page is in English, but the decision it quotes keeps its original Swedish wording: Listen reads that part in Swedish. In English, the quoted text says “The decision becomes final three weeks after it is announced.”
The original wording of a decision
This page is in English, but the decision itself is kept in the language it was issued in. In English, it says: “The decision becomes final three weeks after it is announced.”
Beslutet vinner laga kraft tre veckor efter att det har kungjorts.
import { kvirnSpeechEngine } from '@kvirn-ui/core'
import { Heading } from '@kvirn-ui/react'
import { ReadAloud } from '@kvirn-ui/read-aloud'
import { useRef } from 'react'
import { voiceServiceUrl } from '../../lib/voice-service-url.ts'
import { swedishDecisionText, useReadAloudTexts } from './texts.ts'
const voiceServiceName = 'Kvirn’s voice service'
const engine = kvirnSpeechEngine({ url: voiceServiceUrl, name: voiceServiceName })
export function LanguageOfParts() {
const { texts } = useReadAloudTexts()
const articleRef = useRef<HTMLElement>(null)
return (
<>
<ReadAloud.Root contentRef={articleRef} engine={engine} name={voiceServiceName}>
<ReadAloud.Play />
<ReadAloud.Status />
</ReadAloud.Root>
<article ref={articleRef}>
<Heading as="h4">{texts.language.title}</Heading>
<p>{texts.language.intro}</p>
{/* lang="sv" on just this part (3.1.2 Language of Parts): Listen reads it in Swedish, even
* though the interface around it, and the rest of this article, are in English. */}
<blockquote lang="sv">
<p>{swedishDecisionText}</p>
</blockquote>
</article>
</>
)
}Warning: Don't forget
Put lang on the content itself, not only on the page. Without it, this part would be read with whatever language the page declares (3.1.2 Language of Parts, level AA).
Accessibility#
What it does for you#
- APG pattern: none for the group. Buttons follow Button, the naming practice for media buttons such as Play and Pause.
ReadAloud.Bar's transport follows Toolbar: one Tab stop with rovingtabindex, arrows between the items. - Deviations: none from the APG. Previous, Next and Stop stay focusable while unavailable (
aria-disabled) while idle, so their names can be found and the keyboard path doesn't jump. - Native elements used:
<button type="button">,<select>with a<label>, a plain<span>for the status, a plain<p>for the privacy note.Baris a plain<div>, no role of its own, around aToolbar.Root(role="toolbar");Settingsis aPopover(role="dialog");Hideis a<button>;WhenStartedrenders no element of its own, aFragment.
ReadAloud reads a region of the page aloud for people who benefit from hearing it, using Kvirn's own voice service. It is not a screen reader substitute and never starts by itself.
| Part | Element / role | ARIA | Notes |
|---|---|---|---|
| Root | <div> → group | aria-label = readAloud.label | data-status (idle, preparing, playing, paused), data-error (one of the five below, while an error is current), data-source (content, selection), data-kv-read-aloud-skip (its own words are never read). Renders nothing once hasVoice is false: no voice for the resolved content language, or no engine configured at all |
| Progress | <p>, decorative | aria-hidden="true" | The sentence meter. No progressbar or slider role, no handle, not focusable, no hover or pointer behaviour: position is only ever in words, in Status. Renders nothing while status is idle, since nothing has been read yet |
| Play | <button> → button | none | data-playing while reading; data-busy once a wait (first chunk or a later one) has passed 300 ms. Never disabled: it is the way to cancel the wait. Pause is real: pressing it while paused resumes the same point, never restarting the sentence. Its icon (play/pause/a spinner) and its three possible words are each aria-hidden except the active one, so the name is always exactly the one visible word (2.5.3) |
| Previous | <button> | aria-disabled="true" while idle | Decorative skip-previous icon before the word. Focusable, activation blocked |
| Next | <button> | aria-disabled="true" while idle | Decorative skip-next icon before the word. As Previous |
| Stop | <button> | aria-disabled="true" while idle | Decorative stop icon before the word. As Previous. Reachable during preparing, so a slow service can always be cancelled |
| Transport | <div> | none | Purely structural: groups Previous and Next in the markup so the cluster, its gap and Stop's separation survive a consumer reordering parts. Adds no Tab stop and no role |
| Rate | <select> → combobox | visible <label> | Options 0.75× … 2×, formatted with the provider locale |
| Voice | <select> → combobox | visible <label> | Only voices for the content language. Not rendered with fewer than two. Not part of the default composition: the list is fetched lazily, on the first press or (B4, Plan 0154) as soon as ReadAloud.Voice itself mounts, never eagerly on Root mount (rule 7). Only en currently has a real choice |
| Note | <p> | none | The privacy affordance: names who receives the text, with an optional link. Says nothing is stored (readAloud.note), or that the audio may be (readAloud.noteStored, B5) when the engine's stores is true — never the false sentence regardless of configuration. Renders nothing without name. No consent gate: nothing leaves the browser before Play is pressed regardless |
| SelectionTrigger | <button> → button | popover="manual", tabindex="-1", not aria-hidden | Pointer-only convenience. Name and text readAloud.playSelection. Shown below the end of a selection finished with a pointer; never after a keyboard selection. Never takes focus: pointerdown is prevented, so the selection survives. Dismissed on collapse, any key (Escape included), scroll, resize, Stop and use |
| Status | <span> | role="status" with aria-live="off": findable, silent | Sentence {current} of {total} while reading, Paused at sentence {current} of {total}, Getting the audio… once a wait is visible, One part of the text was skipped after a skip, There is nothing here to read aloud after a press with nothing resolved (B3), or the current error's text. data-error carries the cause for the five machine errors; the no-content notice is a hook-level state, not a machine error, and sets no data-error |
| Bar | <div>, no role | none of its own | ReadAloud.Bar: a plain grouping <div>, nested inside Root's own role="group". One group, not two: while a Bar is mounted, Root's aria-label reads readAloud.barLabel instead of readAloud.label. Carries no lede and no meter; the Status reused inside it (the "count", kv-read-aloud-count) is empty while idle and reads the position while playing, same text as the panel's. Static by default; a theme may make it sticky only while data-status is not idle |
| Toolbar | <div> (Toolbar.Root) → toolbar | aria-label = readAloud.toolbarLabel | ReadAloud.Bar's default composition only (kv-toolbar kv-read-aloud-toolbar): Previous, Play, Next, Stop and Settings as one Tab stop with roving tabindex. Its own name, distinct from the group's readAloud.barLabel and from readAloud.label, so entering it does not repeat a phrase a screen reader already read on the way in |
| Settings | Popover.Trigger → button, Popover.Popup → dialog | aria-haspopup="dialog", aria-expanded; the popup's aria-label = readAloud.settings | ReadAloud.Settings: Speed, Voice, then the recipient sentence (readAloud.note, or readAloud.noteStored with store: true, shown whenever name is known) and, only with a howItWorksHref prop, the readAloud.howItWorks link — shared by the Bar and the panel, one implementation, rendered at either call site. The trigger's name comes from a visible, i18n label span next to the icon, like every other Bar control, not aria-label — so the --words choice class, which only reveals visually hidden text, reaches it too. Never modal, never covers Pause, Previous, Next or Stop (2.2.2) |
| Hide | <button> | aria-label = readAloud.hide | ReadAloud.Bar only. Renders nothing once status is not idle: hiding the only Pause while audio runs would break 2.2.2. Collapses the Bar to one Play button for the rest of the page view (no storage) and moves focus there; nothing is announced |
| WhenStarted | none, a Fragment | none | Renders children once hasEverPlayed is true, else nothing. Reads the Root it is mounted in through context, so the idle-panel composition stays one machine. Adds no element and no Tab stop of its own |
Read aloud#
| State or action | Expected phrase(s) as read aloud | Live region politeness | Planned test (not yet written) |
|---|---|---|---|
| Idle, read top to bottom | group, Listen to this text → button, Listen → button, Stop, disabled → button, Listening settings → the content | none | read-aloud.test.tsx › read aloud › idle reading order: the group, Listen, Stop disabled, Settings, then the content |
| Play pressed, a slow first chunk | button, Pause, then, once preparing has shown for 1 second, polite: Getting the audio… (once per press, never once per sentence) | polite | read-aloud.test.tsx › read aloud › a slow first chunk announces "Getting the audio…" once, past one second |
| Buffering mid-reading | nothing: a later chunk still loading never re-announces preparing | none | read-aloud.test.tsx › read aloud › buffering mid-reading announces nothing |
| Play pressed, then paused | button, Listen → button, Pause + Sentence 1 of 2 → button, Listen + Paused at sentence 1 of 2 | none | read-aloud.test.tsx › read aloud › the Play name reads Listen, then Pause, then Listen after pause |
| A selection is captured | button, Listen to selected text | none | read-aloud.test.tsx › read aloud › the Play name reads Listen to selected text while a selection is captured |
| No voice for the content's language | polite: There is no voice for Finnish yet, so this page can't be read aloud. | polite | read-aloud.test.tsx › read aloud › no voice is announced politely, naming the content's language |
| The voice service is busy | polite: The listening service is busy. Press Listen to try again. | polite | read-aloud.test.tsx › read aloud › a busy service is announced politely, after its one retry |
| The voice service is unavailable | polite: The text can't be read aloud right now. Press Listen to try again, or read on. | polite | read-aloud.test.tsx › read aloud › a service failure is announced politely |
| The browser couldn't play the audio | polite: This browser couldn't play the audio. | polite | read-aloud.test.tsx › read aloud › a playback error is announced politely |
| A part of the text is skipped | nothing: One part of the text was skipped is shown in Status, never announced, and stays shown until Stop (not a few seconds), so a listener who kept going can still find it | none | read-aloud.test.tsx › read aloud › a skipped part is shown until Stop but never announced |
| Play, pause, next, stop, end | nothing | none | read-aloud.test.tsx › read aloud › play, pause and stop announce nothing |
| Bar, idle, read top to bottom | group, Listen to this page → toolbar, Playback controls → button, Previous sentence, disabled → button, Listen → button, Next sentence, disabled → button, Stop, disabled → button, Listening settings → button, Hide the listening bar | none | read-aloud.test.tsx › bar read aloud › idle reading order through the toolbar and Hide |
| Bar, Settings opened | dialog, Listening settings → the Speed select's name and value → the recipient sentence | none | read-aloud.test.tsx › bar read aloud › Settings announces the popup, Speed and the recipient sentence |
| Bar, Hide pressed | nothing: focus moves silently to the one remaining Play button | none | read-aloud.test.tsx › bar read aloud › Hide announces nothing |
Other texts: Speed and Voice labels (readAloud.rate, readAloud.voice), the speed options (readAloud.rateOption, 1.5×), the Note text (readAloud.note) and its howItWorks link, read in the normal reading order like any other static text — not announced.
The phrases are the approximation of a virtual screen reader (software that imitates one for tests), not NVDA or JAWS wording.
The "no voice" row above and Root's own "renders nothing once hasVoice is false" (Roles table) are two different moments, not a contradiction: hasVoice is resolved synchronously at mount from the engine's own voice map (D14), so a language with no voice at all (fi, nn) never renders a player, not even briefly — there is nothing to announce because there is no group to read. The polite "no voice" announcement fires later, during an already-mounted, already-reading session, when a chunk's own resolved voice turns out missing once the real voice list has loaded (error: 'no-voice') — the player is already on screen, so the state is announced in place instead of the player vanishing under the resident.
What you need to do#
- Set
langon the content, not just the page: the voice follows the content's own declared language, never the UI'slocale(3.1.2). Offer the player to everyone: don't auto-start and don't hide it from assistive technology. - Give the engine a
url(directly, or once via<KvirnProvider readAloud>) and aname:NoteandSettingsboth need it to tell residents who the text is sent to. - Wrap the app in
KvirnProvider: errors are announced through it. - Mark what must not be read with
data-kv-read-aloud-skip. ReadAloud.Baronly: withoutcontentRef, it readsscope(a CSS selector) if given, else the page's<main>. `/` HTML comment pairs inside that root narrow it further; they are for server-rendered and CMS markup, since React/JSX cannot emit a comment, and an HTML minifier that strips comments removes them with it.- The disclosure's destination page is yours.
ReadAloud.Settings'showItWorksHrefandReadAloud.Note's own both link to a page you write, explaining that listening sends the text to your chosen service. The library names no URL and does none of this for you: with nohowItWorksHref, there is no link and no dev warning — only the recipient sentence, which already names who receives the text, but a site that sends text to a third-party voice service should still link its own explanation, most usefully from the Bar'sSettings, since a Bar composes no standaloneNote.
Warning: Don't forget
Wrap your app in a KvirnProvider. The player announces its errors through it. Without it, a screen reader user hears nothing when reading stops (4.1.3 Status Messages, level AA).
Visual and modes#
Headless: no CSS. Classes kv-read-aloud, kv-read-aloud-progress, kv-read-aloud-progress-fill, kv-read-aloud-button, kv-read-aloud-play, kv-read-aloud-button-label, kv-read-aloud-transport, kv-read-aloud-previous, kv-read-aloud-next, kv-read-aloud-stop, kv-read-aloud-select, kv-read-aloud-label, kv-read-aloud-status, kv-read-aloud-note, kv-read-aloud-selection-trigger, kv-read-aloud-bar, kv-read-aloud-toolbar, kv-read-aloud-count, kv-read-aloud-settings, kv-read-aloud-settings-popup, kv-read-aloud-hide, the choice classes kv-read-aloud--icons and kv-read-aloud--words, both on Root (hybrid, with the word on Play/Pause only, is the default with no class), and the highlight ::highlight(kv-read-aloud) are for the theme. The highlight is not the only cue: Status shows the sentence position, and a data-busy/data-error icon on Status, in text colour, backs up the spinner and the error text (1.4.1 Use of Color, level A). The meter is the same: decorative length, never the only position cue, since Status already carries the words. Every icon-only control in the Bar still carries its name from i18n in the button's own text (visually hidden by the choice class, not aria-hidden), so its accessible name never depends on the class.
- Focus indicator: the Button's (
data-focus-visible); the selects use the browser's focus ring. - Target size: buttons and selects are native controls at least 24 × 24 CSS px (2.5.8 Target Size (Minimum), level AA), set by the theme.
- Forced colours:
::highlightmaps toHighlight/HighlightText; Status is the position cue either way. - Reduced motion: the sentence scrolls into view only when it is out of view and
prefers-reduced-motionis not set; thepreparingspinner animation is suppressed (the theme's job).
Information: Did you know?
The default theme styles the player but not the sentence highlight. Where the browser supports it (the CSS Custom Highlight API), the sentence being read is registered as ::highlight(kv-read-aloud), and nothing paints it until you add that style. Where the browser doesn't, or you add no style, the Status text is the only cue to which sentence is playing.
Focus management#
- Initial focus: not moved. Focus never leaves the control that was used, including after stop and at the end of the content.
- Trap: no. Restore to: not applicable.
- Never obscured by: the panel composition is in the page flow and never sticky.
ReadAloud.Baris the one exception: static by default, a theme rule may make it sticky only whiledata-statusis notidle; it un-sticks at(max-height: 30rem)instead of covering a focused element, and the consumer setsscroll-padding-block-startto its height. The selection trigger is placed below the selection, beside it when there is no room, and never over the selected text (2.4.11 Focus Not Obscured (Minimum), level AA). - Hide: on press, focus moves to the one remaining Play button in the same place, so it is never lost to the page.
- SelectionTrigger: never takes focus. Any key, Tab included, dismisses it before focus moves, so it never covers a focused element (2.4.11 Focus Not Obscured (Minimum) (AA)). It is not in the Tab order, and it is not hidden from assistive technology. The identical action, and the whole keyboard path, is Play.
- Selection: a selection made in the content is captured, so Tab to Play doesn't lose it. Reading it collapses the selection.
Allowed elements#
A tag outside the list changes the page's outline or semantics (1.3.1 Info and Relationships, level A; 4.1.2 Name, Role, Value, level A). as is a string, so it works from a Server Component.
| Part | `as` | Why |
|---|---|---|
| Status | span (default), p, div | Visible text of the position or the reason nothing is read, with role="status" and aria-live="off" kept. A value outside the list is a type error and, in plain JavaScript, warns once and renders the default element. |
| Root, Progress, Play, Transport, Previous, Next, Stop, Rate, Voice, Note, SelectionTrigger, Bar, Settings, Hide, WhenStarted | none | A role="group" <div>, native <button>s, <select>s, a plain <p> (Progress, Note) and a plain <div> (Transport, Bar), a Toolbar, a Popover, and a Fragment (WhenStarted): no other element keeps the keyboard and name contract (4.1.2 Name, Role, Value, level A) |
WCAG success criteria#
- 2.2.2 Pause, Stop, Hide (A) and 1.4.2 Audio Control (A) do not apply: speech and the highlight start only when the user presses Play. Pause and Stop are offered anyway, reachable during
preparingtoo, and the highlight is cleared on stop and unmount. - 2.1.1 Keyboard (A): every control works from the keyboard.
- 2.4.11 Focus Not Obscured (Minimum) (AA): the SelectionTrigger never takes focus and any key dismisses it before focus moves.
- 3.1.1 Language of Page (A) and 3.1.2 Language of Parts (AA): each chunk is spoken with a voice for its own
lang, never another language's and never the UI'slocale. Unmarked text takes the closest[lang]above it, then the provider'slocale, thenen; an innerlangattribute wins. A chunk with no voice either stops the reading (the content's own language) with a message naming it, or is skipped and read past (an inline, differently-languaged chunk, D10). - 4.1.2 Name, Role, Value (A): the controls have names and roles, and axe finds no violation.
- 4.1.3 Status Messages (AA):
preparing(once per press), the five errors, and nothing per sentence or per skip. - 3.3.1 Error Identification (A): each error says what happened and, where there is one, what to do next (
errorServiceBusy,errorNoVoice,errorNoContent). - 2.5.8 Target Size (Minimum) (AA), 1.4.11 Non-text Contrast (AA): the default theme's job, including the Bar's icon-only controls.
- 2.4.3 Focus Order (A):
ReadAloud.Bar's toolbar keeps the bar at 2–3 Tab stops (toolbar, Settings' popup once open, Hide while idle) ahead of the page's own navigation, which a worded five-button bar would not be. - 3.3.1 Error Identification (A), applied to
scope: a selector or a missing<main>that leaves nothing to read is shown and announced to the resident (readAloud.errorNoContent), not just a development-only warning (B3, Plan 0154) — the devconsole.warnstill fires too, for whoever wiredscope.
Keyboard#
- Focus
- native in the panel; roving
tabindexinsideReadAloud.Bar's toolbar - Selection follows focus
- n/a
- Arrows wrap
- yes, inside the Bar's toolbar (APG Toolbar default)
- Shortcuts
- none
Native controls in DOM order, no tabindex, in the panel. Note is static text, never a Tab stop. Progress (aria-hidden) and Transport (a structural grouping element) add no Tab stop either. Inside ReadAloud.Bar's toolbar, Previous, Play, Next, Stop and Settings are one Tab stop: the last-focused item (or the first, before any has) carries tabindex="0", the rest -1, and the arrows move the roving stop between them (the Toolbar part has its own keyboard contract; the rows below are this component's).
| Key | Where | What happens |
|---|---|---|
| Tab | Player | Moves through Play, Stop, Settings (the default button row, D44) Planned test: read-aloud.test.tsx › keyboard › Tab moves through Play, Stop and Settings |
| Shift+Tab | Player | Moves to the previous control Planned test: read-aloud.test.tsx › keyboard › Shift+Tab moves focus back to the previous control |
| Enter | Play | Reads. Focus stays on Play Planned test: read-aloud.test.tsx › keyboard › Enter on Play starts reading and keeps focus |
| Space | Play | Reads. Focus stays on Play Planned test: read-aloud.test.tsx › keyboard › Space on Play starts reading and keeps focus |
| Escape | Inside the player | Stops reading. Focus stays where it is Planned test: read-aloud.test.tsx › keyboard › Escape inside the player stops reading and keeps focus |
| Escape | Inside the player, idle | Not handled, not prevented Planned test: read-aloud.test.tsx › keyboard › Escape while idle is not prevented |
| Enter | Previous, Next, Stop, idle | Does nothing Planned test: read-aloud.test.tsx › keyboard › Enter on Previous, Next and Stop while idle does nothing and keeps focus |
| Escape | Anywhere, trigger shown | Dismisses the selection trigger Planned test: read-aloud.test.tsx › selection trigger › is dismissed by Escape |
| Arrows, typeahead | Speed, Voice | Native <select> behaviourPlanned test: read-aloud.test.tsx › keyboard › arrow keys on the speed select are not handled or prevented |
| Tab | ReadAloud.Bar | One Tab stop reaches the toolbar; a second reaches Settings' popup once open, a third Hide while idle Planned test: read-aloud.test.tsx › bar keyboard › Tab reaches the toolbar in one stop |
| ArrowRight/Left | ReadAloud.Bar's toolbar | Moves the roving stop between Previous, Play, Next, Stop, Settings, wrapping, flipped in RTL Planned test: read-aloud.test.tsx › bar keyboard › arrow keys move between the toolbar's items |
| Home / End | ReadAloud.Bar's toolbar | Jump to Previous / Settings Planned test: read-aloud.test.tsx › bar keyboard › Home and End jump to the first and last item |
| Enter / Space | Settings trigger | Opens the popup; Escape closes it and returns focus to the trigger Planned test: read-aloud.test.tsx › bar keyboard › Settings opens on Enter and closes on Escape |
| Escape | Settings open, then again | First closes the popup and returns focus to the trigger; a second, inside the player while playing, stops reading (one Escape, one layer) Planned test: read-aloud.test.tsx › bar keyboard › Escape closes Settings before it stops the player |
| Enter / Space | Hide, idle | Collapses the Bar to Play and moves focus to it Planned test: read-aloud.test.tsx › bar keyboard › Hide collapses the Bar and moves focus to Play |
Announcements#
ReadAloud tells screen reader users about these changes without moving focus. Each message waits until the screen reader is quiet (polite) or interrupts it (assertive).
| When | What it says | Message key | Politeness |
|---|---|---|---|
| A wait past 1 second (once per press) | readAloud.preparing | Polite | |
| No voice for the content's language | readAloud.errorNoVoice | Polite | |
| The voice service is busy | readAloud.errorServiceBusy | Polite | |
| The voice service is unavailable | readAloud.errorServiceUnavailable | Polite | |
| The browser couldn't play the audio | readAloud.errorPlayback | Polite | |
Nothing resolved to read (B3, Plan 0154): a misconfigured scope, no <main>, or empty content | readAloud.errorNoContent | Polite |
The text in all five languages
Change the text#
For your whole app, pass messages to KvirnProvider. For one ReadAloud, pass its messages prop.
<KvirnProvider messages={{ readAloud: { preparing: '…' } }}>Warning: Don't forget
Announcements need a KvirnProvider around your app, outside any <form>, or an Announcer of your own. Without one nothing is announced, and a development warning says so.
API reference#
import { ReadAloud, useReadAloud } from '@kvirn-ui/read-aloud'
import { kvirnSpeechEngine } from '@kvirn-ui/core'ReadAloud.Root
Renders <div> with the role group, named by the message readAloud.label. It takes the options of useReadAloud as props and every attribute of a <div> except lang and onKeyDown, and passes ref to it. Renders nothing once it knows the page's language has no voice on the service. Put the other parts inside it. The default theme is described on Theming.
| Prop | Type | Default | Description |
|---|---|---|---|
contentRef | RefObject<Element | null> | Required | The element whose text is read. It is read when Play is pressed. |
scope | string | – | A CSS selector for the element to read, used only while contentRef is not given (ReadAloud.Bar’s own default composition uses this). With neither, the page’s <main> is read. A selector that matches nothing, or no <main> at all, warns once in development and reads nothing. |
engine | ReadAloudEngine | Required | The speech engine: kvirnSpeechEngine({ url }) from @kvirn-ui/core, or a fake for tests. |
name | string | – | Who receives the text, named by the Note part. Pass the same value you gave kvirnSpeechEngine. Left out, the Note renders nothing. |
url | string | URL | the provider’s readAloud.url | Builds the engine for you instead of passing one. Ignored when you pass engine. Without either, and with no provider config, no player renders. |
store | boolean | false | Asks the service to cache the audio. Only for public page text. Used with url. |
timeout | number | 10000 | Total budget per request, in milliseconds. Used with url. |
voices | Readonly<Record<string, string>> | the provider’s readAloud.voices | Which voice reads each language, by BCP 47 tag. Your entries resolve over the service’s own map. The language comes from the content’s lang, then the provider’s locale. |
highlight | boolean | true | Registers the sentence being read as a highlight where the browser supports the CSS Custom Highlight API. Nothing is painted until you style ::highlight(kv-read-aloud). |
scroll | boolean | true | Scrolls the sentence into view when it is out of view. Never when the user prefers reduced motion. |
messages | Partial<KvirnMessages['readAloud']> | – | Overrides the readAloud messages for this player, such as { play: "Listen to the notice" }. |
onStatusChange | (status: 'idle' | 'preparing' | 'playing' | 'paused') => void | – | Called when the status changes. |
| Class or attribute | Values | Meaning |
|---|---|---|
kv-read-aloud | always | The part class. In the content flow it paints no panel: a bare row of buttons (D44). Inside a ReadAloud.Bar it is the full-width band instead. |
kv-read-aloud--icons | your own class, on Root, with a Bar inside | Hides every button’s word in the Bar, Play included, for the smallest possible bar. Each control keeps its name for assistive technology; only the visible text is hidden. |
kv-read-aloud--words | your own class, on Root, with a Bar inside | Shows every button’s word in the Bar, matching the inline row’s look. With neither class, the Bar shows the word on Play only and icons on the rest. |
data-status | idle, preparing, playing, paused | What the player is doing. preparing covers the first press and a mid-text gap. |
data-error | no-voice, speech-error, service-unavailable, service-busy, text-too-long | Why reading stopped, or a part was skipped. Absent otherwise. |
data-source | content, selection | Whether Play reads the whole content or a captured selection. |
data-kv-read-aloud-skip | always | The player’s own words are never read. Put it on content that must not be read too. |
ReadAloud.Progress
Renders <p aria-hidden="true"> wrapping the fill: the sentence meter. No progressbar or slider role, no handle, nothing to drag — it is informative only, since ReadAloud.Status already carries the position in words. Renders nothing while idle.
| Class or attribute | Values | Meaning |
|---|---|---|
kv-read-aloud-progress | always | The part class, on a decorative <p aria-hidden="true">. No progressbar or slider role, no handle: the position is in words, in Status. |
ReadAloud.Play
Renders <button type="button"> with the role button, named Listen, Listen to selected text while a selection is captured, or Pause while reading or getting the audio. It stays pressable while getting the audio, so pressing it is how you stop the wait. A play/pause icon sits before the word, decorative, and is replaced by a spinner past 300 ms of getting the audio. It takes every attribute of a <button> and passes ref to it.
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | the message | Your own text. It replaces the message, so its language is yours to set. |
| Class or attribute | Values | Meaning |
|---|---|---|
kv-button kv-read-aloud-button kv-read-aloud-play | always | The part classes. Previous, Next and Stop share the first two and add their own instead of the third (kv-read-aloud-previous, -next, -stop). SelectionTrigger has its own instead (kv-read-aloud-selection-trigger). |
data-playing | while reading | Play is showing Pause. |
data-busy | past 300 ms of preparing | The wait for the first or next chunk has become visible. Play stays pressable: it is the way to stop the wait. The play/pause icon is replaced by a spinner in the same cell, so nothing moves. |
ReadAloud.Transport
Renders <div> grouping ReadAloud.Previous and ReadAloud.Next: the cluster, its gap, and Stop's separation from it. Adds no Tab stop and no role. It takes every attribute of a <div> and passes ref to it.
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | – | Put ReadAloud.Previous and ReadAloud.Next here. |
| Class or attribute | Values | Meaning |
|---|---|---|
kv-read-aloud-transport | always | The part class, on a plain <div>. Creates the cluster, its gap and the separation from Stop. Adds no Tab stop. |
ReadAloud.Previous
Renders <button type="button"> with the role button, named Previous sentence. It stays focusable with aria-disabled while idle. A decorative icon sits before the word. It takes every attribute of a <button> and passes ref to it.
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | the message | Your own text. It replaces the message, so its language is yours to set. |
ReadAloud.Next
Renders <button type="button"> with the role button, named Next sentence. It stays focusable with aria-disabled while idle. A decorative icon sits before the word. It takes every attribute of a <button> and passes ref to it.
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | the message | Your own text. It replaces the message, so its language is yours to set. |
ReadAloud.Stop
Renders <button type="button"> with the role button, named Stop. It stays focusable with aria-disabled while idle. A decorative icon sits before the word. It takes every attribute of a <button> and passes ref to it.
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | the message | Your own text. It replaces the message, so its language is yours to set. |
ReadAloud.Rate
Renders A native <select> of the speeds with a visible <label>. Changing it changes the speed of the sentence already playing: no new request. It takes every attribute of a <select>.
| Prop | Type | Default | Description |
|---|---|---|---|
label | ReactNode | the message | The visible label. It replaces the message readAloud.rate or readAloud.voice. |
| Class or attribute | Values | Meaning |
|---|---|---|
kv-read-aloud-select | always | The class of the <select>. |
kv-read-aloud-label | always | The class of its <label>. |
ReadAloud.Voice
Renders A native <select> of the voices for the content language, with a visible <label>. It renders only when there are two or more; while the list has not arrived from the service yet, it shows a loading message instead. Not in any composition on this page: today only English has more than one voice.
| Prop | Type | Default | Description |
|---|---|---|---|
label | ReactNode | the message | The visible label. It replaces the message readAloud.rate or readAloud.voice. |
| Class or attribute | Values | Meaning |
|---|---|---|
kv-read-aloud-select | always | The class of the <select>. |
kv-read-aloud-label | always | The class of its <label>. |
ReadAloud.Status
Renders <span> with role="status" and aria-live="off": findable, but silent, since the speech is the feedback. It shows the sentence position, that the audio is on its way, that a part was skipped, or why reading stopped.
| Prop | Type | Default | Description |
|---|---|---|---|
as | 'span' | 'p' | 'div' | 'span' | Changes the element. Another tag warns once and renders a span. |
ref | Ref<HTMLElement> | – | Reaches the element. |
children | ReactNode | the status text | Your own text. It replaces the position or the reason nothing is read. |
| Class or attribute | Values | Meaning |
|---|---|---|
kv-read-aloud-status | always | The part class. |
data-error | no-voice, speech-error, service-unavailable, service-busy, text-too-long | Why nothing is read. |
ReadAloud.Note
Renders <p> naming who the text is sent to, and saying that nothing is stored (readAloud.note) or that the audio may be (readAloud.noteStored, when you set store: true), with your howItWorksHref as a link at the end. Renders nothing when ReadAloud.Root was given no name: there is no sensible text to show without knowing the recipient.
| Prop | Type | Default | Description |
|---|---|---|---|
howItWorksHref | string | – | Shown as a readAloud.howItWorks link at the end of the note, pointing at your own page. Left out, no link is shown. |
children | ReactNode | the note text | Your own text. It replaces readAloud.note, so its language is yours to set. |
| Class or attribute | Values | Meaning |
|---|---|---|
kv-read-aloud-note | always | The part class. |
ReadAloud.SelectionTrigger
Renders <button type="button"> in the top layer, shown below a selection made with a pointer. It never takes focus and is not a Tab stop: the keyboard path is Play. It is named Listen to selected text and takes every attribute of a <button>.
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | the message | Your own text. It replaces the message, so its language is yours to set. |
| Class or attribute | Values | Meaning |
|---|---|---|
kv-button kv-read-aloud-selection-trigger | always | The part classes. |
popover="manual" | always | Puts the button in the top layer below the end of a selection made with a pointer. |
ReadAloud.Bar
Renders <div> with no role or name of its own: it sits inside ReadAloud.Root's own group, which is named readAloud.barLabel while a Bar is mounted. Its default content is a Toolbar of Previous, Play, Next, Stop and Settings (one Tab stop), a status count, and Hide. It takes every attribute of a <div> and passes ref to it.
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | the default toolbar, status count and Hide | Your own markup instead of the default transport. Build it from the part props of useReadAloud. |
| Class or attribute | Values | Meaning |
|---|---|---|
kv-read-aloud-bar | always | The part class, on a plain <div> with no role or name of its own: ReadAloud.Root’s own group is the Bar’s group too. The default theme keeps it static while idle and makes it sticky only while playing. |
ReadAloud.Settings
Renders A Popover trigger button, icon-only and named by readAloud.settings, opening a menu with Speed, Voice and the recipient note. One part works both standalone in the panel and as a toolbar item in the Bar. It takes every attribute of a <button> and passes ref to it.
| Prop | Type | Default | Description |
|---|---|---|---|
howItWorksHref | string | – | Shown as a readAloud.howItWorks link after the recipient sentence, pointing at your own page. Left out, no link is shown and nothing warns: the destination is your own to write. |
children | ReactNode | Speed, Voice, then the recipient note | Your own content for the popup. The trigger button itself stays fixed. |
| Class or attribute | Values | Meaning |
|---|---|---|
kv-button kv-button--icon-only kv-read-aloud-settings | always, on the trigger | The classes of the icon-only button that opens the menu. |
kv-read-aloud-settings-popup | always, on the popup | The class of the menu itself: Speed, Voice, then the recipient note. |
aria-haspopup / aria-expanded | "dialog" / true or false | Tells assistive technology the button opens a menu, and whether it is open. |
ReadAloud.Hide
Renders <button type="button">, icon-only and named by readAloud.hide. ReadAloud.Bar only. Collapses the Bar to its one Play button and moves focus there. Renders nothing once reading has started: hiding the only Pause would leave no way to stop it.
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | a close icon | Your own icon or text, named by readAloud.hide either way. |
| Class or attribute | Values | Meaning |
|---|---|---|
kv-button kv-button--icon-only kv-read-aloud-hide | always | The part classes. |
aria-label | readAloud.hide | Names the button, since its icon is the only visible content. |
ReadAloud.WhenStarted
Renders Nothing of its own: its children only, once reading has started at least once, and nothing before. It never goes back to showing nothing. It reads the ReadAloud.Root it is inside, so there is still one engine, not a second one built separately.
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | – | Shown only once reading has started at least once; nothing before that, and it never goes back to hidden. Not part of the recommended inline row (D44, D47, gated on `status` instead), kept for a consumer's own composition that wants a sticky reveal. Reads the ReadAloud.Root it is inside, so there is still one engine, not a second one. |
kvirnSpeechEngine
Renders nothing: kvirnSpeechEngine(options) from @kvirn-ui/core returns the engine for Kvirn's voice service, for useReadAloud's engine option. These are its options.
| Prop | Type | Default | Description |
|---|---|---|---|
url | string | URL | Required | The service’s base URL: an origin, or a path on your own proxy. Named by none. |
name | string | the URL’s host | Who receives the text, named in the privacy notice. Pass the same value to useReadAloud’s name. |
store | boolean | false | Asks the service to cache the audio. Only for public page text. |
timeout | number | 10000 | Total budget per request, in milliseconds. |
voices | Readonly<Record<string, string>> | the service’s own map | Which voice reads each language, by BCP 47 tag, such as { sv: sv_SE-male-0-medium }. Your entries resolve over the service’s own map. A language with no voice gets no player. |
useReadAloud
Returns the prop objects of every part (rootProps, playProps and so on), the labels and the state. Use it to build the player with your own markup.
Options
| Prop | Type | Default | Description |
|---|---|---|---|
contentRef | RefObject<Element | null> | Required | The element whose text is read. It is read when Play is pressed. |
scope | string | – | A CSS selector for the element to read, used only while contentRef is not given (ReadAloud.Bar’s own default composition uses this). With neither, the page’s <main> is read. A selector that matches nothing, or no <main> at all, warns once in development and reads nothing. |
engine | ReadAloudEngine | Required | The speech engine: kvirnSpeechEngine({ url }) from @kvirn-ui/core, or a fake for tests. |
name | string | – | Who receives the text, named by the Note part. Pass the same value you gave kvirnSpeechEngine. Left out, the Note renders nothing. |
url | string | URL | the provider’s readAloud.url | Builds the engine for you instead of passing one. Ignored when you pass engine. Without either, and with no provider config, no player renders. |
store | boolean | false | Asks the service to cache the audio. Only for public page text. Used with url. |
timeout | number | 10000 | Total budget per request, in milliseconds. Used with url. |
voices | Readonly<Record<string, string>> | the provider’s readAloud.voices | Which voice reads each language, by BCP 47 tag. Your entries resolve over the service’s own map. The language comes from the content’s lang, then the provider’s locale. |
highlight | boolean | true | Registers the sentence being read as a highlight where the browser supports the CSS Custom Highlight API. Nothing is painted until you style ::highlight(kv-read-aloud). |
scroll | boolean | true | Scrolls the sentence into view when it is out of view. Never when the user prefers reduced motion. |
messages | Partial<KvirnMessages['readAloud']> | – | Overrides the readAloud messages for this player, such as { play: "Listen to the notice" }. |
onStatusChange | (status: 'idle' | 'preparing' | 'playing' | 'paused') => void | – | Called when the status changes. |
Result
| Prop | Type | Default | Description |
|---|---|---|---|
status | 'idle' | 'preparing' | 'playing' | 'paused' | – | What the player is doing. |
error | 'no-voice' | 'speech-error' | 'service-unavailable' | 'service-busy' | 'text-too-long' | null | – | Why reading stopped, or null. |
voicesStatus | 'idle' | 'loading' | 'ready' | 'error' | – | Whether the voice list has arrived from the service. |
loadVoices | () => void | – | Fetches the voice list without playing, for a part that needs it before the first press (ReadAloud.Voice calls it on mount). Calling it again does nothing new. |
state | ReadAloudState | – | The full state of the reader. |
hasVoice | boolean | null | – | Whether the content language has a voice on the service. null until the voice list has loaded, so a consumer can render no player for a language with none without flashing it first. |
hasSelection | boolean | – | A selection inside the content is captured: Play reads it. |
hasVoiceChoice | boolean | – | true with two or more voices for the language, which is when a Voice select is useful. |
rootProps | ReadAloudRootPartProps | – | Spread on the group’s element. |
playProps | ReadAloudPlayPartProps | – | Spread on the Play <button>. |
previousProps | ReadAloudButtonPartProps | – | Spread on the Previous <button>. |
nextProps | ReadAloudButtonPartProps | – | Spread on the Next <button>. |
stopProps | ReadAloudButtonPartProps | – | Spread on the Stop <button>. |
rateProps | ReadAloudSelectPartProps | – | Spread on the speed <select>. |
rateLabelProps | ReadAloudLabelPartProps | – | Spread on the speed <label>. |
voiceProps | ReadAloudSelectPartProps | – | Spread on the voice <select>. |
voiceLabelProps | ReadAloudLabelPartProps | – | Spread on the voice <label>. |
statusProps | ReadAloudStatusPartProps | – | Spread on the status element. |
noteProps | ReadAloudNotePartProps | – | Spread on the Note’s <p>. |
noteText | string | null | – | readAloud.note with the recipient’s name, or null when Root was given no name: there is nothing sensible to show without it. |
isSelectionTriggerShown | boolean | – | true after a selection made with a pointer in the content, until it is dismissed. |
selectionTriggerProps | ReadAloudSelectionTriggerPartProps | – | Spread on the <button> shown next to the selection. |
playLabel | string | – | The Play message: Listen, Listen to selected text or Pause. |
playIdleLabel | string | – | The Play message on its own, for building a custom idle label stack. |
selectionLabel | string | – | The selection trigger’s name, and the Play message while a selection is captured. |
pauseLabel | string | – | The Play message on its own, for building a custom pause label stack. |
previousLabel | string | – | The Previous message. |
nextLabel | string | – | The Next message. |
stopLabel | string | – | The Stop message. |
rateLabel | string | – | The speed label. |
voiceLabel | string | – | The voice label. |
howItWorksLabel | string | – | The Note part’s link text, for your own howItWorksHref link. |
voicesLoadingLabel | string | – | Shown only while the Voice select’s options have not arrived yet. |
statusText | string | – | The visible status: the position, a wait, a skipped part, or the reason reading stopped. Empty when idle. |
progressFraction | number | null | – | The sentence meter’s fill, 0 to 1. null while idle, so a custom Progress part can render nothing. |
rateOptions | ReadAloudOption[] | – | The speeds, with formatted labels. |
voiceOptions | ReadAloudOption[] | – | The voices for the content language. |
barLabel | string | – | readAloud.barLabel: the Bar’s own name for the group, used instead of readAloud.label while a Bar is mounted. |
toolbarLabel | string | – | readAloud.toolbarLabel: the name of the Bar’s own toolbar, different from barLabel so a screen reader never hears the same phrase twice on entering the Bar. |
settingsLabel | string | – | readAloud.settings: names the Settings button and its popup. |
hideProps | ReadAloudHidePartProps | – | Spread on the Hide <button>. |
hideLabel | string | – | The Hide message. |
hasEverPlayed | boolean | – | true once reading has started at least once, and never resets. Lets a custom idle panel keep its transport open for the rest of the visit after the first press. |
Strings
These are the default texts in @kvirn-ui/i18n.
For your whole app, pass messages to KvirnProvider. For one ReadAloud, pass its messages prop.
| Message key | Parameters | Default text in English | Used for |
|---|---|---|---|
label | – | Listen to this text | The name of the group. |
play | – | Listen | The name of Play while idle. |
playSelection | – | Listen to selected text | The name of Play while a selection is captured, and of the selection trigger. |
pause | – | Pause | The name of Play while reading or getting the audio. |
previous | – | Previous sentence | The name of Previous. |
next | – | Next sentence | The name of Next. |
stop | – | Stop | The name of Stop. |
rate | – | Speed | The label of the speed select. |
voice | – | Voice | The label of the voice select. |
rateOption | rate | 1.5× | One speed in the select. |
position | current total | Sentence 3 of 12 | The Status while reading. |
positionPaused | current total | Paused at sentence 3 of 12 | The Status while paused. |
preparing | – | Getting the audio… | The Status while the first or next chunk's audio is on its way. Announced once, past a one-second wait. |
errorServiceBusy | – | The listening service is busy. Press Listen to try again. | The Status when the service is busy and the one automatic retry also failed. Also announced. |
errorServiceUnavailable | – | The text can't be read aloud right now. Press Listen to try again, or read on. | The Status when the service can't be reached. Also announced. |
errorPlayback | – | This browser couldn't play the audio. | The Status when the browser couldn't play the audio. Also announced. |
errorNoVoice | language | There is no voice for English yet, so this page can't be read aloud. | Shown beside the article where you choose to, for a language with no voice. |
partSkipped | – | One part of the text was skipped. | The Status after a passage with no voice, or too long for the service, was skipped. Shown only, never announced. |
voicesLoading | – | Loading voices… | Shown by the Voice select while the voice list has not arrived yet. |
note | name | Listening sends this text to Kvirn’s voice service to make the audio. The text and the audio are not saved. | The Note part's text, naming who receives the text. |
howItWorks | – | How listening works | The Note part's link text. |
barLabel | – | Listen to this page | The group's name while a Bar is mounted, instead of label. |
settings | – | Listening settings | Names the Settings button and its popup. |
hide | – | Hide the listening bar | The name of the Hide button, Bar only. |
Known issues#
- Real speech is manual only. Tests use a fake engine; the docs site and Storybook never call the live voice service in CI. The iOS unlock, real voices and the Kvirn service's actual latency need a check with your own users and assistive technology.
- Highlight needs the CSS Custom Highlight API. Without it, Status's position text is the only position cue, which is by design, not a gap.
- fi, nb and nn strings: have a native speaker review them before you launch.
- voice.kvirn.com is not deployed yet. Until it is, every environment but a local dev edge sees the "service unavailable" state.
Information: Did you know?
If an issue here affects your service, list it in your accessibility statement with its workaround.
Testing#
The automated tests prove the keyboard behaviour, the names and states, that axe finds no violations in every story and theme, and, for the components they cover, that the stories hold up in forced colours, reduced motion, text spacing and a 320 pixel width. An Automated row passes on these tests alone. A Core or Release row passes only when an automated agent check and a person on the real assistive technology have both checked it. "agent-verified" means automated tests in the repository (with a virtual screen reader for the screen reader rows), not the real assistive technology.
| AT + browser + OS | Agent check | Human check | Result | Notes |
|---|---|---|---|---|
| Automated (re-runnable tests) | ||||
| axe, WCAG 2.2 A and AA, every story, 4 themes | pending | n/a | pending | read-aloud.stories.tsx, every story state, 4 themes (T7) |
| Markup and ARIA (roles, names, ids, states) | pending | n/a | pending | read-aloud.test.tsx (T7) |
| Keyboard contract rows (Vitest browser) | pending | n/a | pending | the 10 rows above, each its own named test (T7) |
| Focus order and management | pending | n/a | pending | read-aloud.test.tsx (T7) |
| Display modes (forced colours, 320px reflow, text spacing, reduced motion) | pending | n/a | pending | the four sweep projects, run in CI once ReadAloud is added to sweepComponents (T7) |
| Core (required for beta) | ||||
| NVDA + Chrome + Windows | pending | pending | pending | |
| VoiceOver + Safari + iOS | pending | pending | pending | the iOS unlock (the reused <audio> element) is unverified on a real device |
| Release (before 1.0 and each minor) | ||||
| JAWS + Chrome + Windows | pending | pending | pending | |
| TalkBack + Chrome + Android | pending | pending | pending | |
| VoiceOver + Safari + macOS | pending | pending | pending |
What to check#
- Tab through the panel: each control is named. Previous, Next and Stop are read as unavailable while idle.
- Press Enter or Space on Listen: speech starts and focus stays on the button.
- Press Escape while it reads: reading stops and focus stays where it was.
- In the Bar, Tab once to reach the toolbar, then use the arrow keys: focus moves between Previous, Play, Next, Stop and Settings, wrapping at the ends.
- Select text with Shift and the arrow keys, then Tab to Listen: only the selection is read.
- With no voice for the content's language, no player ever appears, not even for a moment.