Content
Table
Data table with caption, column and row headers and optional sorting. Scrolls in its own region when too wide.
- Ready
- Keyboard tested
- Screen reader not tested yet
Playground
Change the props. The controls come from the documented props.
| radius.sm | 4 |
|---|---|
| radius.md | 8 |
| radius.lg | 16 |
<Table
caption="Radius scale"
rowKey="token"
columns={[
{ key: "token", header: "Token", sortable: true },
{ key: "pixels", header: "Pixels", numeric: true, sortable: true },
]}
rows={[
{ token: "radius.sm", pixels: 4 },
{ token: "radius.md", pixels: 8 },
{ token: "radius.lg", pixels: 16 },
]}
/>Usage
When to use
Use a table for data that people compare across rows and columns: lists of records, token values, test results.
When not to use
- For layout.
- For a few facts about one thing: use DescriptionList.
- When there are no rows: use EmptyState instead of headers without content.
How it works
Every table has a caption, visible or for screen readers only. The first column names the row and is a row header. Numeric columns align right with tabular figures. Sortable columns get a button in the header, and the sort state is set as aria-sort. When the table is too wide, it scrolls in its own focusable region.
Content guidelines
The caption says what the table shows. Column headers are short nouns, with units in the header rather than in every cell.
Do and don’t
- LVM Versicherung
- Lead designer
DoA table for rows people compare; facts about one thing go in a DescriptionList. Case facts Label Value Client LVM Versicherung Role Lead designer Don’tA two-column table of label and value: there is nothing to compare.
Do
- Mark number columns as numeric; they align right with tabular figures.
- The first column names the row.
- Link a row through its name (rowLink), so there is one clear target per row.
- Use density="compact" for long lists people scan and compare (logs, many records); keep standard for short lists.
- Offer selection only with at least one bulk action; name the action with what it does to how many (“Assign 3”).
Don’t
- No tables for layout.
- Don't make a column sortable when it holds JSX instead of text or numbers.
- Don't make whole rows clickable; the name link is the target.
- Don't use selection to pick one row for a detail view; link the row instead.
- A destructive bulk action asks first and names the number of rows (Destructive confirmation).
Anatomy
The parts of the component and what each one does, as in the playground above.
- captionNames the table; visible or sr-only.
- header-cellth scope=col, optionally with a sort button.
- sort-buttonToggles ascending/descending; state on aria-sort.
- row-headerFirst cell of each row, th scope=row; a link with rowLink.
- groupOne tbody per group, opened by a th scope=rowgroup with the group name and count.
- scroll-regionNamed region that becomes focusable when it overflows.
- optionWith selectable: a checkbox before each row, named “Select <row name>”, and one for all shown rows (mixed when some are selected).
- actionsWith selectable: a bar above the table with “n of m selected” (live), the bulk actions and “Clear selection”.
Examples
Type-checked, and the same code goes into the AI manifest. Import: import { Table } from "@/ds";
Sortable with a number column
| Utility | ||
|---|---|---|
| spacing.2 | p-2 | 8 |
| spacing.4 | p-4 | 16 |
| spacing.8 | p-8 | 32 |
| spacing.16 | p-16 | 64 |
Caption for screen readers only
| Role | Size (token) | Line height |
|---|---|---|
| text-heading | fontSize.fluid.24-32 | 1.30 |
| text-body | fontSize.18 | 1.65 |
| text-small | fontSize.14 | 1.60 |
Grouped, with row links
| Project | Work | |
|---|---|---|
| 2020s (3) | ||
| Ayvens | Rebranding while running | 2025 |
| LVM Versicherung | Design system & token architecture | 2021 |
| OTTO | Relaunch of the OTTO app | 2020 |
| 2010s (3) | ||
| Deutsche Bahn | Mobile UX & interaction design | 2017 |
| JUKE | Streaming app for movies & series | 2015 |
| MediaMarkt | Design system for two brands | 2014 |
Compact, with selection and a bulk action
| Request | Client | ||
|---|---|---|---|
| Request A | Client C | 2026-11-12 | |
| Request B | Client A | 2026-11-11 | |
| Request C | Client F | 2026-11-10 | |
| Request D | Client B | 2026-11-07 |
Props
Checked against the component's TypeScript type on every build.
| Name | Type | Default | Description |
|---|---|---|---|
| caption (required) | string | – | Names the table and its scroll region. |
| captionHidden | boolean | false | Caption for screen readers only. |
| columns (required) | TableColumn<Row>[] | – | key, header, numeric, fractionDigits, sortable, firstDirection (descending first for dates and amounts). |
| rows (required) | Row[] | – | Data rows; values are text, numbers or ReactNode. |
| rowKey (required) | keyof Row | – | Column with a unique value per row. |
| groupBy | keyof Row | – | Field that groups the rows; each group gets a header row with its count. Sorting happens within groups. |
| rowLink | keyof Row | – | Field with each row's detail URL; the row header becomes a link. |
| density | "standard" | "compact" | "standard" | compact halves the vertical cell padding for long lists people scan; controls keep their size. |
| selectable | boolean | false | A checkbox per row and one for all shown rows, for actions on several rows at once. |
| selected | string[] | – | Controlled selection (rowKey values as strings); use with onSelectedChange. |
| defaultSelected | string[] | – | Selection at the start, when the table keeps it itself. |
| onSelectedChange | (keys: string[]) => void | – | Called with the new selection. |
| bulkActions | ReactNode | ((keys: string[]) => ReactNode) | – | Actions for the selected rows, in a bar above the table while something is selected; a function gets the selected keys (client components only). |
| defaultSort | { key: keyof Row; direction: "ascending" | "descending" } | – | Initial sort order. |
Tokens used
Derived from the utility classes in the component's source. Copy a class with one click.
| Token | Tier | Value | Utility |
|---|---|---|---|
| button.radius | component | 9999px | |
| choice.border | component | #8A8578 | |
| choice.checked | component | #0A0A0B | |
| choice.mark | component | #FAFAF7 | |
| choice.radius | component | 4px | |
| choice.size | component | 24px | |
| input.bg | component | #FAFAF7 | |
| input.radius | component | 8px | |
| table.bg | component | #FFFFFF | |
| table.border | component | rgba(10,10,11,0.08) | |
| table.cellPadding | component | 16px | |
| table.cellPaddingCompactY | component | 8px | |
| table.headerFg | component | #555555 | |
| table.numeric.fontVariantNumeric | component | tabular-nums | |
| table.radius | component | 16px | |
| table.rowSelectedBg | component | #EFEDE6 | |
| focus | semantic | #C6492E | |
| spacing.0 | semantic | 0px | |
| spacing.1 | semantic | 4px | |
| spacing.2 | semantic | 8px | |
| spacing.3 | semantic | 12px | |
| spacing.4 | semantic | 16px | |
| surface.page | semantic | #FAFAF7 | |
| surface.subtle | semantic | #E7E3DA | |
| text.primary | semantic | #0A0A0B | |
| text.secondary | semantic | #555555 | |
| type.small.size | semantic | 14px | |
| weight.medium | semantic | 500 | |
| weight.regular | semantic | 400 | |
| weight.semibold | semantic | 600 |
Accessibility
What is checked automatically on every build, and what a person has tested. Nothing is marked as tested unless it was.
| Check | How | Status |
|---|---|---|
| axe-core rules | Automated on every npm run check, at desktop and mobile width | Runs on every build |
| Keyboard | Automated Playwright test (scripts/keyboard.mjs) | Tested |
| Screen reader | Manual | Not tested yet |
Keyboard
| Key | Action |
|---|---|
| Tab | Moves to the next sort button, or to the scroll region when it overflows. |
| Enter / Space | Toggles the sort order of the focused column. |
| Arrow keys | Scroll the focused region. |
| Space | With selectable: checks or unchecks the focused row or all rows. |
Semantics and focus
- <caption> is required, visible or sr-only.
- <th scope="col"> and scope="row" for the first column.
- Sorting through a button in the header; the state is aria-sort on the <th>.
- When too wide, the region becomes focusable and scrolls with the keyboard.
- Groups are tbody elements opened by <th scope="rowgroup">, so screen readers announce the group with its rows.
- Selection: native checkboxes named after the row; the all-rows box is mixed (indeterminate) when only some are selected. The count is a live status.
- Selected rows get a quieter tone as support; the checkbox carries the state.
Contrast
| Pairing | Ratio (x:1) | Minimum | Status |
|---|---|---|---|
| text.primary on surface.page | 18.92 | 4.5 | Pass |
| text.primary on surface.card | 19.79 | 4.5 | Pass |
| text.secondary on surface.page | 7.13 | 4.5 | Pass |
| text.secondary on surface.card | 7.46 | 4.5 | Pass |
| text.onInverse on surface.inverse | 18.92 | 4.5 | Pass |
| border.control on surface.page | 3.52 | 3.0 | Pass |
| border.control on surface.card | 3.68 | 3.0 | Pass |
| focus on surface.page | 4.57 | 3.0 | Pass |
| focus on surface.card | 4.78 | 3.0 | Pass |
| text.primary on surface.subtle | 15.45 | 4.5 | Pass |
| text.primary on surface.sunken | 16.89 | 4.5 | Pass |
| text.secondary on surface.sunken | 6.36 | 4.5 | Pass |
| focus on surface.sunken | 4.08 | 3.0 | Pass |
| text.secondary on surface.subtle | 5.82 | 4.5 | Pass |
| surface.inverse on text.onInverse | 18.92 | 4.5 | Pass |
| surface.inverse on surface.subtle | 15.45 | 4.5 | Pass |
| border.control on surface.inverse | 5.38 | 3.0 | Pass |