Accessibility
Keyboard-only use, what screen readers hear, high contrast and reduced motion, and what to take care of in your app
The grid follows the WAI-ARIA grid pattern. It works with the keyboard alone, and moving the active cell makes screen readers read that cell. This page sums up what the grid does and what your app should add.
Keyboard
- One
Tabin, oneTabout. Buttons inside the grid (the header's⋮, group row toggles, detail toggles) aren't in theTaborder; inside the grid you move with the arrow keys.Tabin the last column /Shift+Tabin the first column moves to the next / previous element outside the grid. - Header actions:
Alt+↓(Option+↓on Mac) on the active cell opens the column menu of that column. Sorting, filters, pinning, autosizing and column visibility are all there. - Context menu:
Shift+F10/ the Menu key (the application key on Windows) on the active cell opens the context menu of that cell (enableContextMenu) (since 1.1.0). - Expand and collapse: group rows and detail toggles use
Enter/Spaceon the active cell. Rows of tree data useAlt+Shift+↓(expand) /Alt+Shift+↑(collapse) on a cell of the tree column (Enteredits, so it isn't used). - Popovers and menus: the column menu and context menu receive focus whether opened by mouse or key; arrow keys move between items and
Escape/Tabcloses them. In the column filter popover and the tool panel,Tabcycles inside; closing withEscapereturns focus to the grid for the column filter, and to the part that opened it (such as the filter summary in the top bar) for the tool panel. - Where focus is: focus is shown by the outline of the active cell. When there is no active cell, as right after entering with
Tab, an accent-colored (--ssg-accent) outline appears inside the table (not after touching it with the mouse). - Find and replace:
Ctrl/Cmd+Fin the grid (Ctrl+Hto open the replace row as well) opens the find bar and moves focus to the search field.Enter/Shift+Entergoes to the next / previous match, andTabmoves through ↑ ↓ × → the replacement field → Replace → Replace all → "In selection".Enterin the replacement field replaces.Escfrom anywhere in the bar closes it and returns to the grid. After returning to the grid with the bar still open,Ctrl/Cmd+F/Ctrl+Htakes you back to the search field. When no match is left, the replace buttons only getaria-disabledand keep focus (Find in cells). - Page scrolling: moving the active cell with the keyboard also scrolls scrolling parents around the grid and the page as little as needed to bring the active cell into view.
The list of keys is in Keyboard and touch.
Actions only a pointer can do
The following can be done only with a mouse or touch. If keyboard-only users need them too, make your app's buttons do the same. Opening and closing column groups (columnGroups) works from the keyboard too (the "Collapse …" / "Expand …" item at the top of the column menu opened with Alt+↓ on the active cell).
| Pointer action | What keyboard or your app's buttons can do instead |
|---|---|
Context menu of a row number (target.type is 'rowHeader') | Keys open only the active cell's menu (target.type: 'cell'), so also put row actions in the cell menu or in your app's buttons |
| Dragging a column width | "Autosize this column" in the column menu. For a fixed width, applyState({ columnWidths }) from your app's button |
| Dragging to reorder columns (including the grip of column group headers) | Reorder the columns you hold with onColumnsChange from your app's buttons |
Pressing a column group header (columnGroups) to select its columns / dragging its right edge to resize | Select the range of its columns with Shift+Arrow. Widths through applyState({ columnWidths }) from your app's button |
Row drag (enableRowDrag) | A button that calls the handle's moveRow |
Fill handle (fillHandle) | Copy (Ctrl/Cmd+C) and paste (Ctrl/Cmd+V) |
Screen readers
-
Name of the table: give the table a name with
ariaLabel. Always do so when you put several grids on one screen.<SpreadsheetGrid ariaLabel="Orders" rows={rows} columns={columns} /> -
Reading cells: the
aria-activedescendantof the focused element points at the active cell, so assistive technology reads the cell every time you move with the arrow keys. Rows and columns not rendered because of virtualization aren't in the DOM, so the position within the whole table is conveyed witharia-rowindex/aria-colindex/aria-rowcount/aria-colcount. -
Menus and panels: the column menu is
role="menu"(named after the column), its items aremenuitem, and the ascending / descending sort and "Pin column" items aremenuitemradio+aria-checked. The header's⋮hasaria-haspopup="menu"/aria-expanded. The context menu isrole="menu"too, named "Cell menu" when opened on a cell and "Row menu" when opened on a row number (names since 1.2.0). The tool panel and column filter popover are namedrole="dialog"(non-modal) (roles of the column menu and tool panel since 1.1.0). -
Tree data: with
treeData, the table isrole="treegrid"; rows getaria-level(top = 1) /aria-setsize/aria-posinset, and rows with visible children getaria-expanded. The toggle is named "Expand Sales" ("Expand Row 3" for rows with an empty name) (since 1.9.0). -
Pagination: the pager is a
<nav>(named 「ページ」 = textpaginationLabel); the current page's number button hasaria-current="page", and changing the page announces the row range 「51–100 / 1234 行」 in an invisible region (aria-live="polite").aria-rowindexand row numbers are continuous across all pages. With several paginated tables on one screen, give each pager its own name withpaginationLabelinlocaleText(for example "Order pages"). A pager you draw yourself withrenderBottomBarisn't announced, so add your ownaria-live(Pagination) (since 1.15.0). -
Find bar:
role="search"; match counts and replace notices arearia-live="polite"(repeated notices with the same text still reach the reader). The ▸ of the replace row hasaria-expanded. -
State: cells in the selection are
aria-selected, cells that can't be edited arearia-readonly, the header of the first sort key isaria-sort, and loading rows (serverSide) arearia-busy. -
Validation and notes: cells that fail validation are
aria-invalid, and messages and notes (cellNote) are conveyed througharia-description(the same text as the tooltip). Unsaved cells of change tracking (trackChanges) also usearia-description, "Unsaved (was 120)", and rows with unsaved cells say "Has unsaved changes" in the row number'saria-description(Change tracking). The message when a'reject'column can't be committed isrole="alert"(Validation). -
Diff view and range decorations: in the diff view (
baselineoftrackChanges), changed cells say "Changed (was 120)" inaria-description, added rows and changed rows say "Added row" / "Has changes" in the row number'saria-description, and removed rows are named "Removed row". The ▲ ▼ in the bottom bar are buttons named "Previous change" / "Next change", and where you land is announced in a hidden region (aria-live="polite") like "Unit price of P1: Changed (was ¥100) (1 of 3)". Removed rows also take a position in the view, soaria-rowindexcounts them (Diff view). The frames and labels of range decorations (rangeDecorations) aren't read (aria-hidden); when a cell inside a range becomes active, the label is added to itsaria-description(Range decorations) (both since 1.13.0). -
Editors: the editor being used has a name such as "
Edit Qty" and is conveyed as being inside the cell being edited (aria-owns). The select editor is a combobox and listbox (thesearchselect's input is a combobox witharia-autocomplete="list", and options convey the total and their position witharia-setsize/aria-posinset; Searchable select editor). -
Button names: every button the grid draws has a spoken name, such as the header's
⋮("Column menu for Qty"), row checkboxes ("Select row 3"), detail toggles ("Show details for row 3"; row number since 1.3.0) and group toggles ("Expand Tokyo"). The row drag handle and detail toggle columns keep an empty-looking header but are named "Move" / "Details" for screen readers (since 1.3.0; the textsrowDragColumnName/detailColumnName). The names above are the English texts oflocaleTextEn(English and text); without it, the default Japanese names are read.
The list of roles and attributes per element is in "Accessibility" in SpreadsheetGrid props.
Look
- Reduce motion: the default
motion="auto"stops animations when the OS / browser "reduce motion" setting (prefers-reduced-motion: reduce) is on. To always stop them, usemotion="off"(Motion). - High contrast: where the browser replaces colors with system colors (
forced-colors: active), such as Windows high contrast, parts that relied on color alone (invalid cells, note marks, unsaved marks, conditional format chips) are drawn with borders and symbols (Theming). - Contrast: among the default colors, secondary text such as in the tool panel doesn't reach WCAG AA's 4.5:1 (conditional format chips have been 5:1 or more in all 5 colors since 1.3.0). Token values to override to meet the standard are in "Raising contrast" in Theming.
- Row height and padding: change row height and padding with
density('compact'/'standard'/'comfortable') androwHeight. Make them roomier on screens where ease of pressing comes first.
What to take care of in your app
- Buttons and links you place with
renderCellneed a name, either visible text oraria-label. The grid doesn't know their contents. Buttons in cells aren't stops forTabin the last column, so if keyboard users need to press them, also put the row actions in a detail row card or in your app's buttons. - Custom editors (
editor: { type: 'custom' }) need a name on their input, like the built-in editors (aria-label={`Edit ${title}`}and so on). - Don't convey meaning by color alone: when you color cells with
cellClassName/getRowClassNameto show a state, add text or a symbol too (thechipsof conditional formatting show symbols by default). - A grid in a dialog: the grid's popups (column menu, filters, select options and so on) appear inside the dialog around the grid by default, so they work even when a modal traps focus (since 1.1.0; change the place with
popupContainer; see Use it inside a dialog). TheEscapethe grid uses (cancelling an edit and so on) doesn't close the dialog; pressing it again does (Keyboard and touch).
Known limitations
- With pinned columns (
pinned), one row is split into a row (role="row") per left / center / right pane. They all have the samearia-rowindex, but the reading order is per pane. - The band of a detail row (
detailRow) has noaria-rowindex(so data row numbers don't shift). The copy of a vertically pinned label row (labelRow.sticky) isaria-hidden, and the real label row is the one read. - While editing, checkers such as axe may report
aria-required-childrenon the table. The editor is drawn outside the row and linked from the cell being edited witharia-owns, so in the browser's accessibility tree it's a child of the cell (checked in Chrome), but checkers count an element moved witharia-ownsas a child of its original parent too.
Saving and restoring state
Save the column widths, filters, sorting and column order / visibility / pinning users changed, and bring them back next time (getState / applyState / initialState / restoreColumnsFromState)
Use it inside a dialog
Where popups go (popupContainer) and Escape when you put the grid in a modal or popover