Skip to content
Cynosurev0.5.0
SearchStorybookGitHubnpmColour mode: System. Switch to Light

Components / Foundations

LiveRegion

A hidden live region for screen reader announcements that belong to one component: "Copied", "Moved to position 3 of 8", "Zoom 150%", "3 of 12". It is a foundation: it has no visual output. For announcements from anywhere in an app, use Announcer and useAnnounce(), which speak through LiveRegions near the root.

Announces politely

Who uses itLink to "Who uses it"

Announcer, CopyButton, DocumentViewport, FileDrop, HotkeyField, PanZoomCanvas, SearchField, SortableList, Tabs, TagInput and VirtualList.

When to use it directlyLink to "When to use it directly"

When a component you build announces the outcome of its own actions, or a value it shows (a match count, a zoom level), and must work without an Announcer above it, or speaks elements (a Kbd) rather than strings.

Use something else when the message comes from app code rather than a component: Announcer. When the message is visible text: Notice or Toast, which are live regions themselves.

UsageLink to "Usage"

tsx
Copy
import { LiveRegion, useLiveMessage } from "@arshad-shah/cynosure";

function Saver() {
  const [message, say] = useLiveMessage();
  return (
    <>
      <Button onClick={() => save().then(() => say("Draft saved"))}>Save</Button>
      <LiveRegion {...message} />
    </>
  );
}

// Following a value: announced when the words change, not on every render.
<LiveRegion>{`${count} results`}</LiveRegion>

PropsLink to "Props"

Every prop of LiveRegion
PropWhat it doesTypeDefault
children
What screen readers announce: text or elements (a Kbd). Empty ("", null, false) says nothing.ReactNode
sequence
Changes with every announcement, so the same words twice in a row are read twice (useLiveMessage gives it). Omit it to announce only when the words change.number
politeness
polite (default, role="status") or assertive (role="alert", for errors).Politeness
className
Added to the region, for the owning component's own rules (a reset, a hidden-host fix).string

Generated from the type definitions in @arshad-shah/cynosure 0.5.0.

useLiveMessage() returns [message, say]. say(words) announces the words, again when they are the same as last time; say("") clears the region without a sound. Spread message on the region.

Behaviour and accessibilityLink to "Behaviour and accessibility"

  • Polite by default: role="status", aria-live="polite", aria-atomic="true". politeness="assertive" makes it role="alert", for errors.
  • Always in the page: the region is rendered empty from the start, so screen readers have registered it before the first message.
  • Repeats are read: each say puts the words in a new node (a new sequence), and screen readers read added content, so pressing Copy twice is announced twice. There is no clear-then-set step and no timer.
  • Elements: the message may hold elements; a Kbd is read by its spoken name ("Control plus K").
  • Hidden: out of sight with .cy-visually-hidden (one pixel, clipped), never display: none or aria-hidden, so it stays in the accessibility tree, and steady under hostile host CSS.

Announcer, VisuallyHidden.

These examples run Cynosure 0.5.0 (commit 50ce30b), the version on npm.

Getting started
Theming
Icons
Accessibility
Code editors and highlighters
Using Cynosure without React
Build-tool adapters
Components
Accordion
AppShell
AspectRatio
Breadcrumbs
Calendar
Card
Container
Disclosure
Divider
DocumentViewport
Grid
Inline
PageHeader
PanZoomCanvas
ScrollArea
SideNav
SortableList
SplitPane
Stack
StatusBar
Tabs
TitleBar
Toolbar
Tree
VirtualList
ZoomControls
Announcer
Avatar
Badge
CodeBlock
DescriptionList
EmptyState
ErrorBoundary
Field
Heading
IconTile
Image
Kbd
List
LoadingDots
Notice
ProgressBar
Prose
Skeleton
Stat
Steps
Table
Text
Button
Checkbox
Checklist
ColorField
ColorSwatches
Combobox
CompareSlider
CopyButton
DateField
FileDrop
IconButton
KeyValueEditor
Link
NumberField
Pagination
PathField
RadioGroup
SearchField
SegmentedControl
Select
SelectionFrame
SignaturePad
Slider
Switch
TagInput
TextArea
TextField
ThemeToggle
TimeField
ButtonBase
ChoiceBase
DialogBase
FileInputBase
HiddenValue
Icon
InputBase
LinkBase
LiveRegion
TextAreaBase
ChatMessage
Choice
DataGrid
DeviceFrame
HighlightedText
HotkeyField
ListRow
OptionList
OverlayFrame
QRCode
RowActions
Section
SiteFooter
SiteHeader
SkipLink
SortButton
VisuallyHidden
CommandPalette
ContextMenu
Dialog
FloatingToolbar
HoverCard
Menu
Menubar
Popover
ProgressOverlay
Sheet
Toast
Tooltip
Changelog