View as Markdown

Accessibility

Accessibility

One ARIA grid tree, the keyboard map, live-region announcements, focus across virtualization and overlays, accessible names, contrast, reduced motion and forced colors.

The grid targets WCAG 2.2 AA in every state. This page shows what an application gets and what it must provide.

One grid tree

DataGrid renders a single role="grid" element. The header, body and footer are rowgroups inside it, rows are rows, header cells columnheaders and body cells gridcells; toolbar, search, pager and menus use toolbar, search, navigation and menu roles. The grid sets aria-rowcount and aria-colcount to the full size, each row and cell its aria-rowindex and aria-colindex (so virtualized rows keep their real positions), and aria-sort, aria-selected, aria-expanded (on the group and detail toggles, never on a row), aria-busy, aria-rowspan / aria-colspan where they apply.

One ARIA tree, no split header table

The grid does not split into a header table and a content table stitched together with aria-owns, because that produces two ARIA trees and axe-core warnings. Salmon UI keeps one tree in one scroll container, so aria-owns is unnecessary and axe-core reports zero violations. One tree also keeps the sticky header and the body in one scroll path. To style or test the header or the body, target the header and body parts (classNames / styles); to reach their elements, call api.getPartElement('header') or api.getPartElement('body').

Accessible name

Give every grid a name with aria-label or aria-labelledby; a development warning names the grid when both are missing. aria-describedby points at help text. The demo labels the grid with its visible heading.

<h2 id="orders-title">Customer orders</h2>
<DataGrid aria-labelledby="orders-title" aria-describedby="orders-help" data={orders} columns={columns} />

Keyboard

The grid is one Tab stop: exactly one element inside it has tabindex="0", and Tab / Shift+Tab leave it. The bindings, with macOS variants:

Keys Behavior
Arrow keys Move cell focus (left and right flip in RTL)
Home / End First / last cell of the row
Ctrl+Home / Ctrl+End (⌘+Home / ⌘+End) First / last cell of the grid
PageUp / PageDown One viewport up / down
Alt+J / Alt+W Focus the grid root / the grid content
F6 / Shift+F6 Cycle through the toolbar, group panel, header, body, footer and pager
Enter on a header Sort; Ctrl/⌘+Enter adds to a multi-column sort, Shift+Enter removes it
Alt+ArrowDown / Shift+Alt+ArrowDown on a header Filter menu / column menu
Space Toggle the selection of the focused row
Shift+Arrow Extend the selection
Ctrl/⌘+A Select all rows
Shift+F10 Context menu
Escape Close the open menu, then cancel editing, then clear the range

Remap any command with keyBindings and intercept keys with onKeyDown (see Data Grid API and keyboard hooks); the default table is exported as DEFAULT_KEY_BINDINGS from @salmonui/data-grid/engine.

<DataGrid keyBindings={{ 'selection.selectAll': ['Mod+Shift+L'] }} aria-label="Orders" data={orders} columns={columns} />

Screen reader announcements

Each grid renders a polite live region and announces sort, filter, search, selection, paging, loading, column moves and pins, edits and export progress, localized through localeText and debounced so only the latest message is read. Cell content is read from the DOM; icons are aria-hidden and icon-only buttons carry aria-label. The demo copies the live region into a visible log.

Every grid state is checked with axe-core, and the accessibility tree a screen reader reads (roles, names, states and live regions) is pinned by ARIA snapshot tests. Column headers are named by their label only, so the resize handle and header buttons are not repeated on every column move. There is no screen reader automation: JAWS, NVDA and VoiceOver are not tested.

Focus across virtualization and overlays

Focus is logical: the grid remembers { rowId, field }, not a DOM node. When the focused cell scrolls out of the rendered window, the grid root keeps the tab stop and the next arrow key or the remounted cell brings DOM focus back to the same cell. Menus, dialogs and the column chooser push their invoker on a focus stack, and closing returns focus to it. api.focusCell(rowId, field) scrolls a cell into view and focuses it.

Contrast, reduced motion and forced colors

  • The derived palette guarantees at least 7:1 for body text, 4.5:1 for secondary text and 3:1 for borders, focus ring and selection, in light and dark, for any valid color seed. Try your own seeds in the theme colors demo.
  • prefers-reduced-motion: reduce leaves no transition or animation in the grid; prefers-contrast: more moves borders and text to higher-contrast steps (secondary, placeholder and semantic text at least 7:1, default borders 4.5:1, strong borders 7:1) and widens the focus ring to 3px; forced-colors: active switches to system colors, with selection in Highlight / HighlightText and a visible focus outline.

Tests

  • tests/browser/a11y.spec.ts: axe-core in every built state (default, focused, selected, sorted, dark, RTL, forced colors, prefers-contrast: more with measured text and border ratios) with zero violations.
  • tests/browser/keyboard.spec.ts: the keyboard map in LTR and RTL with Windows and macOS variants.
  • packages/core/tests/theme.test.ts: contrast guarantees for the default seeds and 20 random seed sets, standard and prefers-contrast: more.
  • docs/site/tests/accessibility.spec.ts: this page's demo (axe-core, roles, keyboard, live region, focus restoration, forced colors).

Keyboard and screen reader

Open demo

One labelled role="grid" tree over 2,000 virtualized rows - the keyboard map, a single tab stop, live-region announcements mirrored below the grid, and focus that survives virtualization and menus.

Customer orders

2,000 orders. Arrow keys move between cells, Enter on a header sorts, Space selects a row.

Order
Customer
Country
Product
Amount
Shipped
ORD-10000
Hana Sato
Japan
Grinder
$438.60
ORD-10001
Elif Kaya
Portugal
Green tea
$26.36
ORD-10002
Goran Petrov
Malaysia
Kettle
$389.40
ORD-10003
Chen Wei
Japan
Pour-over kit
$107.10
ORD-10004
Elif Kaya
Japan
Pour-over kit
$151.20
ORD-10005
Bao Nguyen
Malaysia
Kettle
$233.64
ORD-10006
Elif Kaya
Portugal
Pour-over kit
$478.80
ORD-10007
Hana Sato
Germany
Filter beans
$119.00
ORD-10008
Bao Nguyen
Japan
Filter beans
$126.00
ORD-10009
Bao Nguyen
Germany
Filter beans
$100.80
ORD-10010
Jun Park
Malaysia
Grinder
$774.00
ORD-10011
Bao Nguyen
Germany
Green tea
$7.86
ORD-10012
Hana Sato
France
Espresso beans
$140.60
ORD-10013
Farah Aziz
Germany
Oolong tea
$80.33
ORD-10014
Chen Wei
France
Kettle
$496.49
ORD-10015
Jun Park
Malaysia
Kettle
$61.66
ORD-10016
Jun Park
Germany
Green tea
$74.00
ORD-10017
Chen Wei
Malaysia
Oolong tea
$72.68
ORD-10018
Chen Wei
Portugal
Green tea
$49.95
ORD-10019
Goran Petrov
Germany
Pour-over kit
$294.00
No events yet.

API

The ARIA props (aria-label, aria-labelledby, aria-describedby), keyBindings, onKeyDown and localeText are on DataGridProps; focus, focusCell, focusHeader and getPartElement are on DataGridApi, and the default key table is DEFAULT_KEY_BINDINGS.