Data display
Table
A data table for scanning and comparing records.
columns: key, label, optionalrender,align,width,sortable(+sortValue). Right-align numbers and dates you compare.selectableadds a checkbox column; pair with TableToolbar for bulk actions.rowActionsadds a ⋯ menu column.- Header on
surface-muted; rows divided byborder-subtle; hoversurface-hover; selectedaccent-subtle. footerholds Pagination.density="compact"for long lists. GiveemptyTextthat says why it's empty.- Long text wraps (IDs and URLs break anywhere). Per column:
truncate: truekeeps one line with an ellipsis (setwidth),nowrap: truefor codes and dates. Right-aligned columns never wrap and set their figures in the numeric font (IBM Plex Sans by default, tabular digits);numeric: truedoes the same for any other column,numeric: falseopts out. Row checkboxes are labelled "Select row …" from the first column.
When to use
Compare many records across columns; sort, select and act in bulk.
Use something else
Few fields per record → List. Status workflow → Kanban. One record's details → DescriptionList.
Do
- Right-align numbers and money; keep IDs
nowrap. - Use
selectablewith TableToolbar for bulk actions;density="compact"for long lists. - Give
emptyTextthat says why it's empty.
Don't
- Don't put more than one or two actions in a row; use the ⋯ row action.
- Don't nest tables.
Props
| Prop | Type |
|---|---|
columns required | Array<{ key: string; label: string; render?: (row: any) => React.ReactNode; align?: 'left' | 'right' | 'center'; width?: number | string; sortable?: boolean; truncate?: boolean; nowrap?: boolean; /** Figures in the numeric font with tabular digits; defaults to true for right-aligned columns. */ numeric?: boolean; sortValue?: (row: any) => any }>; rows: Array<object & { id?: string |
selected | boolean }>; selectable?: boolean; defaultSelected?: string[]; onSelectionChange?: (ids: string[]) => void; defaultSort?: { key: string; dir: 'asc' | 'desc' }; rowActions?: boolean; footer?: React.ReactNode; density?: 'default' | 'compact'; emptyText?: string; className?: string |
Use
const { Table } = window.Tessera;
const el = React.createElement(Table, { /* props */ });