Accessibility
cherry's components meet WCAG 2.2 AA when used as documented. Keeping that true in an app depends on a few things only the app can provide, listed under What you must provide. Each component page has its own Accessibility section.
How cherry is tested
On every push, CI runs the component playground through axe (WCAG 2.2 AA rules):
- in light and dark mode,
- at a desktop width (1280px) and at 320px,
- with every popup open (menus, dialogs, pickers).
It also checks what axe cannot:
- visible focus on every kind of tab stop,
- focus traps and focus return for dialogs and sheets,
- outlines in forced colors (Windows High Contrast),
- placeholder contrast,
- reflow at 320px.
What cherry handles
- Roles, states and names on every component:
role="switch",aria-expanded,aria-current,aria-invalid, labelled close and copy buttons, live regions for toasts and results counts. - Keyboard support for every widget, following the WAI-ARIA patterns (see the table below).
- Focus: a visible ring on every focusable element, in both modes and in Windows High Contrast. Dialogs and sheets move focus in, trap it, and return it to the trigger. Popovers and menus return focus on Escape.
- Contrast: text tokens meet 4.5:1 (except
--cherry-fg-subtle, which is for disabled and decorative use only). Focus rings and control borders meet 3:1. - Target size: controls are at least 24 by 24px, or spaced so they don't collide (WCAG 2.5.8).
- Reflow: nothing forces sideways scrolling at 320px (400% zoom). Tables and code scroll inside their own focusable region.
- Motion: every transition uses the motion tokens, which shrink to 1ms under
prefers-reduced-motion: reduce. - Text spacing: no clipping when users increase line, letter and word spacing (WCAG 1.4.12).
What you must provide
1. A name for every control
- Form controls: wrap them in
<Field label="...">, or passaria-labelwhen a visible label is impossible. A placeholder is not a label. IconButton:aria-labelis required. The same goes for an icon-onlyKbd, aToggleGroupItemwith only an icon, andConfirmButton(make it specific: "Delete report.pdf").- Groups: name a
RadioGrouporToggleGroupwitharia-labelor a surroundingField.
import { Field, IconButton, Input } from "@cherry-design-system/react";
import { Search, Trash2 } from "lucide-react";
<Field label="Search">
<Input leadingIcon={<Search />} placeholder="Name or email" />
</Field>
<IconButton aria-label="Delete report.pdf" icon={<Trash2 />} />2. Errors through Field
Pass the message as <Field error={...}>. It sets aria-invalid on the control and links the text so it is read with the field. Don't show errors only as red borders.
<Field label="Email" required error={errors.email}>
<Input type="email" name="email" />
</Field>3. Distinct landmark names
When a page has two Paginations, several Banners, two Sidebars or two Table scroll regions, give each a different name (labels={{ nav: "Results pages" }}, aria-label, navLabel, scrollLabel).
4. Real headings and structure
Use CardTitle level={...}, EmptyState headingLevel, and <h1> to <h6> in order. Put page content in <main>.
5. Meaning beyond color
Status, trend and severity must be in text too: Badge text, Callout titles, StatCard trendLabels. Name destructive menu items clearly ("Delete project").
6. Alt text
Avatar takes alt (defaults to name). Images you render need alt, empty (alt="") when decorative.
7. Translations
Every built-in string is a prop (closeLabel, dismissLabel, copyLabel, labels, statusLabels and others). Translate them along with your UI.
8. Your own components
Hold them to the same bar: a visible :focus-visible ring (outline: 2px solid transparent; box-shadow: var(--cherry-ring)), --cherry-fg-muted or stronger for readable text, 24px targets, and the motion tokens. See Styling.
9. Don't hide focus or meaning
Never set outline: none without a replacement ring, never put essential information only in a Tooltip, and never disable zoom.
Keyboard patterns
| Component | Keys |
|---|---|
| Button, IconButton, Link, Toggle, Checkbox | Tab to focus; Enter or Space activates (Space toggles switches and checkboxes) |
| RadioGroup, ToggleGroup (single), ThemeToggle | Arrows move and select; one tab stop for the group |
| Tabs | Left and Right move and select; Home and End go to the first and last |
| Menu | Enter, Space or ArrowDown open; Up and Down move; Home and End; Escape closes and returns focus |
| Combobox, SearchDialog | Type to filter; Up and Down highlight; Enter selects; Escape closes |
| Select | Native select keys |
| Calendar (and the DatePicker grid) | Arrows move by day and week; PageUp and PageDown by month (with Shift, by year); Home and End go to the start and end of the week |
| TimePicker | Up, Down, Home, End, Enter; Left and Right move between the hour, minute and AM/PM columns |
| NumberField | Up and Down step; PageUp and PageDown take a large step; Home and End go to min and max |
| Range | Arrows step; PageUp and PageDown; Home and End |
| OTPInput | Type to advance; Backspace goes back; Left, Right, Home, End; paste fills every slot |
| Modal, Sheet, DatePicker, ChatPanel drawer | Focus moves in and stays in; Escape closes; focus returns to the trigger |
| Popover, Tooltip | Escape closes; Tooltip also shows on keyboard focus |
| Accordion | Enter or Space toggles (native <details>) |
| ChatInput | Enter sends; Shift+Enter adds a new line |
| Table, CodeBlock, Snippet (when wider than their box) | Tab to the region; arrows scroll |
Testing your app
- Automated: run axe (for example
@axe-core/playwright) on your pages in light and dark, at a desktop width and at 320px, and with menus, dialogs and pickers open. axe does not check::placeholdercontrast or focus visibility, so test those separately. - Keyboard: unplug the mouse and Tab through the page. Every stop shows a ring, nothing is skipped or trapped, and every popup closes with Escape and returns focus.
- Screen reader: VoiceOver (Safari) and NVDA (Firefox or Chrome). Check names on icon buttons, errors read with their fields, toasts announced once without stealing focus, and dialog titles read on open.
- Zoom and contrast: 200% browser zoom and the OS text size; Windows High Contrast (or Chrome's forced-colors emulation). Focus and selected states must stay visible.
// e2e/a11y.spec.ts
import { test, expect } from "@playwright/test";
import AxeBuilder from "@axe-core/playwright";
for (const mode of ["light", "dark"] as const) {
test(`home has no axe violations in ${mode}`, async ({ page }) => {
await page.addInitScript((m) => localStorage.setItem("themePreference", m), mode);
await page.goto("/");
const results = await new AxeBuilder({ page })
.withTags(["wcag2a", "wcag2aa", "wcag21aa", "wcag22aa"])
.analyze();
expect(results.violations).toEqual([]);
});
}