TableHeaderCell
A table header cell (<th>). scope=col (default) carries an optional three-state DS-Icon sort control and aria-sort; scope=row marks the identifying cell of a body row so screen readers announce the row context with every other cell.
Status: stable. Group: data-display. Markdown version: /design-system/components/table-header-cell.md
When to use
TableHeaderCell names a column or row with correct scope semantics, and hosts sortable column headers driven by useTableSortable; sort state is announced via aria-sort, never by caret colour alone.
When not to use
- Do not render it outside a table.
- Do not make a scope=row header sortable; row headers are not sort controls.
- Do not convey sort state with the caret colour alone.
Look-alikes
- TableCell: Do not use it for a header; use TableHeaderCell so column/row context is announced.
Props
| Prop | Type | Default | Description | Required |
|---|---|---|---|---|
align | "center" | "end" | "start" | start | Cell content alignment. | No |
scope | "row" | "col" | col | Header scope. col (default) labels a column; row makes the cell the accessible name for its row; use it on the identifying cell of each body row so screen readers announce the row context with every other cell. | No |
sortable | boolean | none | Renders the sort button, which calls onSort on click; the consumer owns sortDirection. Column headers only: with scope="row" it is silently ignored and no button renders. Without onSort the button does nothing. | No |
sortDirection | "none" | "ascending" | "descending" | none | Current sort state; drives aria-sort and the caret icon. Column headers only; ignored with scope="row". | No |
onSort | () => void | none | Called when a sortable header is activated. | No |
Variants
- Allowed
alignvalues:start,center,end(defaultstart). - Allowed
scopevalues:col,row(defaultcol). - Allowed
sortDirectionvalues:none,ascending,descending(defaultnone).
Invalid combinations
The contract records no invalid combinations.
Keyboard
| Key | Behaviour |
|---|---|
| Tab | Moves focus to the control and on to the next focusable element. (standard) |
| Enter | Activates the focused control. (standard) |
| Space | Activates or toggles the focused control. (standard) |
Rows marked (standard) name a key the contract lists without a description; the behaviour shown is the usual one for that key.
Rules
Every item under When not to use is a MUST NOT. MUST and SHOULD follow RFC 2119.
| Level | Rule | How it is checked |
|---|---|---|
| MUST | ARIA: Native <th> with an explicit scope (col or row) | Not yet verified: no evidence record. WCAG 4.1.2. |
| MUST | ARIA: Sortable column headers expose aria-sort and toggle via an inner button. | Not yet verified: no evidence record. WCAG 4.1.2. |
| MUST | ARIA: The sort caret is decorative (aria-hidden); state is carried by aria-sort, never the icon alone. | Not yet verified: no evidence record. WCAG 4.1.2. |
| MUST | Required stories produce no axe violations at the configured severity. | Automated by npm run test:stories:matrix:ci. WCAG 2.5.8. |
| MUST | The accessibility tree (role, name, state) matches the committed snapshot for every required story. | Automated by npm run test:stories:matrix:ci. WCAG 1.3.1, 4.1.2. |
| MUST | The component remains legible and operable under a real browser forced-colors: active pass. | Automated by npm run test:stories:hc. |
| MUST | Every documented keyboard interaction works as specified. | Not yet verified: no evidence record. WCAG 2.1.1, 2.1.2. |
| MUST | A human completed an end-to-end accessibility review of this component. | Manual review, last on 2026-11-04. |
Install and import
- Install:
npm install @digitaltableteur/react(version 0.9.1, restricted access on npm). - Import:
import { TableHeaderCell } from "@digitaltableteur/react"; - Entry point:
@digitaltableteur/react/contentexports it too. - Styles: import
@digitaltableteur/react/style.cssonce at the app boundary.
Links
- Machine-readable contract (Design System Contract 1.0)
- Markdown version of this page
- Component index as JSON
- All components
- Source: The implementation lives in a private repository. This page, its Markdown twin and the contract are generated from it at build time and are the public source of truth.