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

Components / Feedback and display

Announcer

Tells screen reader users about changes that happen without moving focus, such as "Draft saved" or "12 results". <Announcer> renders two hidden live regions inside your app; useAnnounce() speaks through the nearest one.

Announces politely

When to useLink to "When to use"

  • A change with no visible message, or with one somewhere the person is not looking: a save finished, a filter changed the result count, an item was copied.

Use something else when:

  • a visible message suits everyone: Toast or Notice (both announce themselves)
  • focus moves to the new content anyway: moving focus is its own announcement

UsageLink to "Usage"

Render one Announcer near the root of your app, inside your CynosureTheme:

tsx
Copy
import { Announcer, useAnnounce } from "@arshad-shah/cynosure";

<Announcer>
  <App />
</Announcer>

function Results({ count }: { count: number }) {
  const announce = useAnnounce();
  useEffect(() => announce(`${count} results`), [count, announce]);
  …
}

announce(message) is polite: the screen reader finishes what it is saying first. Pass { politeness: "assertive" } to interrupt; keep that for errors.

Announces errors assertively

PropsLink to "Props"

Every prop of Announcer
PropWhat it doesTypeDefault
clearAfter
Milliseconds before an announcement is cleared from the hidden region. Default: 5000.number5000
children
Your app. Anything inside can announce through useAnnounce().ReactNode

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

Behaviour and accessibilityLink to "Behaviour and accessibility"

  • Regions: a role="status" region (polite) and a role="alert" region (assertive), both atomic and visually hidden but present for assistive technology.
  • Repeats: each announcement is a new text node, so the same message twice is read twice.
  • Clearing: messages are removed after clearAfter milliseconds (5000), so they do not linger for someone browsing the page later.
  • Isolation: the regions render where the Announcer is. Nothing is appended to <body>.
  • Nesting: useAnnounce() uses the nearest Announcer; an extension can give each mounted panel its own.
  • Missing provider: without an Announcer above it, announce does nothing and warns once in the console.

ThemingLink to "Theming"

No tokens: the regions are never seen.

Toast · Notice · ProgressBar

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