Components
Table
Hand-composed table whose header and rows share one column template and restack by container width.
import { Table } from "@openperf/deft";
<Table.Root aria-label="Endpoints" columns="minmax(0,1fr) 96px">
<Table.Body>
<Table.Row>
<Table.Cell>GET /api/projects</Table.Cell>
<Table.Cell numeric>1,204</Table.Cell>
</Table.Row>
</Table.Body>
</Table.Root>;When to use
| Need | Component |
|---|---|
| Short set of rows you render yourself, with fixed columns | Table |
| Rows from data and column definitions, with sorting, selection, loading and empty state | Data table |
| Records or settings with a label, a description and a control | List |
| Attributes of a single object | Key value |
Anatomy
<Table.Root columns="16px minmax(0,1fr) 96px">
<Table.Header>
<Table.HeaderCell />
</Table.Header>
<Table.Body>
<Table.Row>
{/* Table.Row or Table.ExpandableRow */}
<Table.SelectCell /> {/* optional leading checkbox */}
<Table.Cell>
<Table.RowLink /> {/* optional; its click area covers the row */}
</Table.Cell>
</Table.Row>
</Table.Body>
<Table.Group>
{/* collapsible section of rows */}
<Table.Row />
</Table.Group>
<Table.Loading /> {/* skeleton rows */}
<Table.Empty /> {/* empty state */}
</Table.Root>columns is a CSS grid-template-columns value shared by the header and every row: give it one track per cell, including the leading track for Table.SelectCell and for the chevron of Table.ExpandableRow. Table.Group, Table.Loading and Table.Empty go directly inside Table.Root, not inside Table.Body.
Responsive layout
The layout follows the width of the table's own container, not the viewport. When the columns do not fit, the table scrolls horizontally.
| Container width | Layout |
|---|---|
Below 52rem | compactColumns replaces columns. Cells and header cells with priority="low" are hidden. |
Below 36rem | The header and cells with priority="medium" are hidden too, and each row wraps by area: lead first, title taking the free space, aside at the right, every meta cell on a second line in small muted text. label appears in front of the value. |
Header and sorting
onSort turns the header content into a button, and sort shows the direction arrow. Table reorders nothing: keep the sort state and sort the rows yourself.
Row links and selection
Table.RowLink stretches over the whole row, and Table.SelectCell sits above it, so its checkbox toggles without navigating. Pass aria-label to Table.SelectCell: it has no label of its own.
A row with onClick is focusable: Enter activates it and Space toggles the checkbox of its Table.SelectCell. Arrow Up and Arrow Down move focus between clickable rows, row links and expand toggles, skipping rows in a collapsed group.
Expandable rows
Table.ExpandableRow adds a leading chevron cell and renders panel under the row while it is open. Leave it uncontrolled with defaultOpen, or control it with open and onOpenChange.
Grouped rows
Groups are open by default. leading goes between the chevron and the title, and count at the right edge of the heading.
Loading
Table.Loading renders eight skeleton rows unless rows says otherwise.
Empty
Table.Empty shows the empty state over a faded backdrop of ghost rows. It takes the props of Empty.Root; fill it with the parts of Empty.
API
Table.Header and Table.Body declare no props of their own.
Table.Root
Prop
Type
Table.HeaderCell
Prop
Type
Table.Row
Prop
Type
Table.Cell
Prop
Type
Table.RowLink
Takes the props of an <a>.
Prop
Type
Table.SelectCell
Takes the props of Checkbox.Root from Checkbox except size, such as checked, indeterminate and onCheckedChange.
Table.ExpandableRow
Prop
Type
Table.Group
Prop
Type
Table.Loading
Prop
Type