Data display
Table
A native <table> with column sorting and row selection. Screen readers get real table navigation, row and column headers, and aria-sort — no grid role to learn.
import { Table } from '@reactloom/ui';Examples
Sortable
Click a header to sort; again to reverse. Values sort by type, strings with the locale’s collation.
| Status | ||||
|---|---|---|---|---|
| INV-1046 | Hooli | Pending | 2026-10-18 | $2,975.25 |
| INV-1045 | Umbrella | Paid | 2026-10-15 | $310.00 |
| INV-1043 | Globex | Pending | 2026-10-09 | $860.50 |
| INV-1042 | Acme Corp | Paid | 2026-10-02 | $1,250.00 |
| INV-1044 | Initech | Overdue | 2026-09-21 | $4,200.00 |
import { Badge, Table, type TableColumn } from '@reactloom/ui';
import { invoices, type Invoice } from './data';
const tone = { Paid: 'success', Pending: 'warning', Overdue: 'danger' } as const;
const money = new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD' });
const columns: Array<TableColumn<Invoice>> = [
{ key: 'id', header: 'Invoice', sortable: true },
{ key: 'customer', header: 'Customer', sortable: true },
{ key: 'status', header: 'Status', cell: (r) => <Badge tone={tone[r.status]}>{r.status}</Badge> },
{ key: 'issued', header: 'Issued', sortable: true },
// Sorts by the number; renders formatted currency.
{ key: 'amount', header: 'Amount', sortable: true, align: 'end', cell: (r) => money.format(r.amount) },
];
export default function Example() {
return (
<div style={{ width: '100%' }}>
<Table caption="Invoices" columns={columns} rows={invoices} getRowId={(r) => r.id} defaultSort={{ column: 'issued', direction: 'descending' }} />
</div>
);
}Selection
Controlled selection with a mixed select-all and disabled rows.
1 selected
| Customer | Status | Amount | |
|---|---|---|---|
| Acme Corp | Paid | $1,250.00 | |
| Globex | Pending | $860.50 | |
| Initech | Overdue | $4,200.00 | |
| Umbrella | Paid | $310.00 | |
| Hooli | Pending | $2,975.25 |
import { Button, HStack, Stack, Table, Text, type TableColumn } from '@reactloom/ui';
import { useState } from 'react';
import { invoices, type Invoice } from './data';
const money = new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD' });
const columns: Array<TableColumn<Invoice>> = [
{ key: 'customer', header: 'Customer' },
{ key: 'status', header: 'Status' },
{ key: 'amount', header: 'Amount', align: 'end', cell: (r) => money.format(r.amount) },
];
export default function Example() {
const [selected, setSelected] = useState<string[]>(['INV-1043']);
return (
<Stack gap="3" style={{ width: '100%' }}>
<HStack gap="3" align="center">
<Text size="sm" tone="muted">{selected.length} selected</Text>
<Button size="sm" variant="secondary" disabled={selected.length === 0} onClick={() => setSelected([])}>
Send reminders
</Button>
</HStack>
<Table
caption="Unpaid invoices"
hideCaption
selectionMode="multiple"
selectedIds={selected}
onSelectionChange={setSelected}
isRowDisabled={(r) => r.status === 'Paid'}
columns={columns}
rows={invoices}
getRowId={(r) => r.id}
density="compact"
/>
</Stack>
);
}Empty state
| Name | Owner |
|---|---|
No projects match “billing”Try another search term. | |
import { EmptyState, Table } from '@reactloom/ui';
export default function Example() {
return (
<div style={{ width: '100%' }}>
<Table
caption="Search results"
columns={[
{ key: 'name', header: 'Name' },
{ key: 'owner', header: 'Owner' },
]}
rows={[] as Array<{ id: string; name: string; owner: string }>}
getRowId={(r) => r.id}
emptyState={<EmptyState size="sm" headingLevel={4} title="No projects match “billing”" description="Try another search term." />}
/>
</div>
);
}API reference
Table props
| Prop | Type | Default |
|---|---|---|
columnsrequired | TableColumn<Row>[] | — |
rowsrequired | Row[] | — |
getRowIdrequiredStable id per row. | (row) => string | — |
caption · aria-labelNames the table (and its scroll region). | ReactNode · string | — |
hideCaption | boolean | false |
sort / defaultSort / onSortChange | { column, direction } | null | — |
manualSortingRows arrive sorted (server-side). | boolean | false |
selectionMode | 'none' | 'multiple' | 'none' |
selectedIds / defaultSelectedIds / onSelectionChange | string[] | — |
isRowDisabled | (row) => boolean | — |
emptyState | ReactNode | 'No data' |
density | 'comfortable' | 'compact' | 'comfortable' |
striped | boolean | false |
maxHeightScroll inside with a sticky header. | string | — |
selectAllLabel · selectRowLabelTranslate these. | string | 'Select all rows' · 'Select' |
TableColumn
| Prop | Type | Default |
|---|---|---|
keyrequiredAlso the default property read from each row. | string | — |
headerrequired | ReactNode | — |
cell | (row) => ReactNode | — |
sortable | boolean | false |
sortValueDefaults to row[key]. Empty values sort last. | (row) => string | number | Date | boolean | null | — |
alignUse end for numbers. | 'start' | 'center' | 'end' | 'start' |
width | string | — |
rowHeaderCells become row headers (default: first column). | boolean | — |
textValueFor announcements when header is not text. | string | — |
Customization
Extracted from the component’s source on every build, so it matches the code. How the layers fit together is explained in Customization.
State attributes
Target these in your CSS to style states without depending on class names.
| Attribute | Values |
|---|---|
[data-active] | present when on |
[data-align] | present when on |
[data-density] | compact · comfortable |
[data-scroll-y] | present when on |
[data-selected] | present when on |
[data-striped] | present when on |
Theme tokens it reads
--pl-color-accent-subtle --pl-color-bg-muted --pl-color-bg-subtle --pl-color-bg-surface --pl-color-border-default --pl-color-fg-default --pl-color-fg-muted --pl-focus-ring-color --pl-focus-ring-offset --pl-focus-ring-width --pl-font-size-sm --pl-radius-lg --pl-radius-sm
Accessibility
- Native table semantics: screen readers announce row and column headers as users move between cells.
- Sortable headers contain a button; the header exposes aria-sort and the change is announced politely.
- Row checkboxes are named by the row header (“Select Acme Corp”); select-all shows a mixed state.
- The scroll container is a named, focusable region so wide tables can be scrolled with the keyboard.
| Key | Action |
|---|---|
| Tab | Move between sort buttons, checkboxes and interactive cells |
| Enter / Space | Sort by the focused column, or toggle a checkbox |
Usage guidelines
Do
- Right-align numbers and sort them by their value, not their formatted text.
- Use manualSorting with server-side data and paginate with Pagination.
Don’t
- Don’t use a table for layout.
- Don’t put many interactive widgets in every cell — this is a table, not a spreadsheet-style grid.