Examples

Sortable

Click a header to sort; again to reverse. Values sort by type, strings with the locale’s collation.

Preview
Invoices
Status
INV-1046Hooli2026-10-18$2,975.25
INV-1045Umbrella2026-10-15$310.00
INV-1043Globex2026-10-09$860.50
INV-1042Acme Corp2026-10-02$1,250.00
INV-1044Initech2026-09-21$4,200.00
Example.tsx
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.

Preview

1 selected

Unpaid invoices
CustomerStatusAmount
Acme CorpPaid$1,250.00
GlobexPending$860.50
InitechOverdue$4,200.00
UmbrellaPaid$310.00
HooliPending$2,975.25
Example.tsx
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

Preview
Search results
NameOwner

No projects match “billing”

Try another search term.
Example.tsx
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

Table props
PropTypeDefault
columnsrequired
TableColumn<Row>[]—
rowsrequired
Row[]—
getRowIdrequired
Stable id per row.
(row) => string—
caption · aria-label
Names the table (and its scroll region).
ReactNode · string—
hideCaption
booleanfalse
sort / defaultSort / onSortChange
{ column, direction } | null—
manualSorting
Rows arrive sorted (server-side).
booleanfalse
selectionMode
'none' | 'multiple''none'
selectedIds / defaultSelectedIds / onSelectionChange
string[]—
isRowDisabled
(row) => boolean—
emptyState
ReactNode'No data'
density
'comfortable' | 'compact''comfortable'
striped
booleanfalse
maxHeight
Scroll inside with a sticky header.
string—
selectAllLabel · selectRowLabel
Translate these.
string'Select all rows' · 'Select'

TableColumn

TableColumn
PropTypeDefault
keyrequired
Also the default property read from each row.
string—
headerrequired
ReactNode—
cell
(row) => ReactNode—
sortable
booleanfalse
sortValue
Defaults to row[key]. Empty values sort last.
(row) => string | number | Date | boolean | null—
align
Use end for numbers.
'start' | 'center' | 'end''start'
width
string—
rowHeader
Cells become row headers (default: first column).
boolean—
textValue
For 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.

AttributeValues
[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.
Keyboard interactions
KeyAction
TabMove between sort buttons, checkboxes and interactive cells
Enter / SpaceSort 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.