Table
Styled native table primitives (Th, Td, Tr, TableFooter, TableContainer) that read CSS modules for token-driven spacing and typography.
Component behavior
Table styles application-provided Tr, Th, and Td elements. It does not infer columns or rows. Use it for spanning cells, grouped headers, or other custom table markup.
- Tables with spanning cells, nested headers, or mixed content.
- Small static tables with application-defined markup.
- Custom cell markup.
DataGrid: column definitions should manage rendering, sorting, and selection.
TreeTable: rows nest into a hierarchy.
DescriptionList: the view displays one record’s fields.
VirtualList: large row counts require virtualization.
Th
Th extends ThHTMLAttributes<HTMLTableCellElement>.
| Prop | Type | Default | Description |
|---|---|---|---|
num | boolean | — | Right-aligns and uses monospace numerals. |
sortable | boolean | — | Turns the header into the column's sort control: a full-cell button with a direction glyph and the matching aria-sort. |
sortDirection | "asc" | "desc" | null | — | The direction this column is sorted in; null when it is not the sorted column. |
onSortChange | (direction: SortDirection | null) => void | — | Called with the next direction: initial direction, reverse, then null for unsorted. |
defaultSortDirection | "asc" | "desc" | num ? "desc" : "asc" | Where an unsorted column starts. |
Td
Td extends TdHTMLAttributes<HTMLTableCellElement>.
| Prop | Type | Default | Description |
|---|---|---|---|
num | boolean | — | Right-aligns and uses monospace numerals. |
name | boolean | — | Bold name-styled cell for row identifiers. |
mono | boolean | — | Monospace font for codes, hashes, IDs. |
Tr
Tr extends HTMLAttributes<HTMLTableRowElement>.
| Prop | Type | Default | Description |
|---|---|---|---|
hover | boolean | — | Shows a hover highlight on mouse-over. |
attn | boolean | — | Applies a background tint to highlight the row. |
sel | boolean | — | Selected state with highlight. |
dimmed | boolean | — | Low-contrast muted row. |
TableFooter
TableFooter extends HTMLAttributes<HTMLDivElement>. Renders a footer bar below the table.
| Prop | Type | Default | Description |
|---|---|---|---|
right | ReactNode | — | Slot pinned to the right side of the footer. |
TableContainer
TableContainer extends HTMLAttributes<HTMLDivElement>. Wraps a table in a scrollable container for overflow handling.
TableContainerProps has no custom props.
Table
Table extends HTMLAttributes<HTMLTableElement>. The core <table> element with Onset styling.
| Prop | Type | Default | Description |
|---|
Examples
Basic table with all variants
Sortable columns
sortable renders a full-width button in the header cell. The application stores the sorted column and direction. Clicks cycle through the starting direction, reverse direction, and null for unsorted. Ignore null when an unsorted state is not supported.
With footer
Row states
import {
Table,
TableContainer,
Th,
Td,
Tr,
TableFooter,
} from "@solarius/onset";
import type {
ThProps,
TdProps,
TrProps,
TableFooterProps,
} from "@solarius/onset";