This page as markdown: /table.md · Index for agents: /llms.txt · Everything in one file: /llms-full.txt
Table
Status: stable
Styled native table subcomponents (Table, TableHeader, TableBody, TableFooter, TableRow, TableHead, TableCell, TableCaption). Horizontally scrollable frame, hairline row borders, hover-lift, selectable rows via data-selected, and sortable column headers (TableHead sortable).
Keywords: table, data table, rows, columns, grid, caption, header, cell, tabular
Usage
Use Table for structured data with consistent columns and rows. Use DataTable when the table should be data-driven with sorting or empty state behavior, and use lists or cards when each item has a different shape.
Best practices
- Do: Use TableCaption and TableHead so the table has a clear purpose and column semantics.
- Do: Keep cells concise and scannable; compose Badge, StatusDot, Avatar, or Button only when they clarify the row.
- Do: Use the built-in horizontal frame for overflow instead of squeezing columns until content becomes unreadable.
- Do: Put a table in a card with
<CardContent flush>. The first and last columns then take the card's own padding (--table-edge-px), so they line up with the CardHeader at any density. Never hand-setpl-6/pr-6on edge cells. - Don't: Use Table for heterogeneous items with no stable columns. Use Card, Entity, or a list composition instead. → use Card, Entity
- Don't: Put every possible action in every row. Use one primary row action, an OverflowMenu, or row detail navigation.
Anatomy
| Part | Required | Description |
|---|---|---|
| Caption | no | Accessible summary of what the table contains. |
| Header | yes | Column labels rendered with TableHead cells. |
| Body | yes | Rows and cells containing the tabular data. |
| Footer | no | Optional totals or summary row group. |
Subcomponents
| Name | Type | Description |
|---|---|---|
| TableHeader | ComponentPropsWithRef<"thead"> | The header row group (thead). |
| TableBody | ComponentPropsWithRef<"tbody"> | The data row group (tbody). |
| TableFooter | ComponentPropsWithRef<"tfoot"> | Summary row group (tfoot) with a muted fill. |
| TableRow | ComponentPropsWithRef<"tr"> | A row (tr) — hairline bottom border, hover lift, and a selected state via the data-selected attribute. |
| TableHead | ComponentPropsWithRef<"th"> & { numeric?: boolean; sortable?: boolean; sortDirection?: "asc" | "desc" | null; onSort?: () => void } | A column header cell (th) in muted label styling. numeric marks a number column: end-aligned, tabular figures — set it on the column's cells too. sortable turns the header's content into the sort control: a ghost button on the column's text edge that calls onSort, with one chevron that rotates for sortDirection (resting at 60% when unsorted; leading in a numeric column) and aria-sort on the cell. The table does not sort — order the rows in onSort, or use DataTable, which renders this part. |
| TableCell | ComponentPropsWithRef<"td"> & { numeric?: boolean } | A data cell (td). numeric end-aligns it with tabular figures, matching its column's header. |
| TableCaption | ComponentPropsWithRef<"caption"> | Accessible description of the table (caption), muted. |
Props
| Name | Type | Default | Description |
|---|---|---|---|
| className | string | — | The root renders a horizontally scrollable frame around a native Tokens used
Motion
Accessibility
Related
ExamplesOrders
Rich status cells
Sortable headers
Flush in a card
Summary footer
|