DataTable

Figma
Github
Storybook

DataTable enables users to act upon complex datasets with a variety of features including filtering and sorting.

Structure

The DataTable component is built with semantic HTML table elements (<table>, <thead>, <tbody>, <th>, <td>) so it may constructed similarly to any normal table. A visually hidden <caption> is required and provides an accessible name for screen reader users. Header cells automatically receive scope="col" or scope="row" depending on their position.

Using HTML elements under the hood ensures that DataTable subcomponents maintain their inherent accessible roles for assistive technology.

ARIA

The DataTable applies ARIA attributes based on the features enabled:

table
ElementAttributeDescription
Row selection checkboxaria-labelDescribes the action: "Select row" / "Deselect row" for individual rows, "Select all rows" / "Deselect rows" for the header checkbox.
Row expand/collapse buttonaria-labelUpdates to reflect the current state: "Expand" / "Collapse" for individual rows, "Expand all" / "Collapse all" for the header button.
Row action menu triggeraria-labelIdentifies the row the action menu belongs to.
Pagination regionaria-labelSet to "Pagination" to identify the navigation region.
Pagination buttonaria-labelLabels each button with its function (e.g., "First page", "Previous page", "Next page", "Last page").
Virtualized tablearia-rowcountConveys the total number of rows in the dataset.
Virtualized table rowaria-rowindexConveys the row's position within the full dataset.
Selected rowaria-selectedSet to true on rows that are currently selected.
Sortable column headeraria-sortSet to ascending, descending, or none to communicate the current sort state.

Keyboard

Table

table
KeyFunction
TabMoves focus to the next focusable element within or after the table (sortable headers, checkboxes, expand buttons, row action buttons).
Shift+TabMoves focus to the previous focusable element.

Pagination

table
KeyFunction
Enter/SpaceActivates the focused pagination button.
TabMoves focus to the next pagination control.
Shift+TabMoves focus to the previous pagination control.

Row actions

table
KeyFunction
Enter/SpaceOpens the row action dropdown menu.
EscapeCloses the dropdown.
Moves to the next item in the dropdown.
Moves to the previous item in the dropdown.

Row expansion

table
KeyFunction
Enter/SpaceExpands or collapses a row when its expand button is focused.

Row selection

table
KeyFunction
SpaceToggles selection of a row when its checkbox is focused.

Sorting

table
KeyFunction
Enter/SpaceToggles the sort direction on a focused sortable column header. Selects the radio option highlighted. Activates the focused "Sort" button.
EscapeCloses the "Sort" button dropdown.
Moves to the radio in the group.
Moves to the previous radio in the group.