DataTable
The v3 mock's .tbl (one list engine for every list): a real <table> in a bordered wrapper (radius 18), a #FAFAFC uppercase head, sortable headers (a button with ↕ / ↑ / ↓; the th carries aria-sort), rows that open on click, Enter or Space with a trailing › (mirrored in RTL), a #FBF6F8 hover. Under 860px each row is a stacked card with its column labels; density="tight" is the mock's .tbl.tight (9px cell padding). Controlled: sort / onSort and the page live with the screen (useListState).
import { DataTable } from '@ergasti/bricks';Examples
Sortable table
Headers with a sortKey are buttons; the table is controlled: it tells you the new DataSort and you sort the rows. The first click sorts high to low unless the column says sortFirst: 'asc'. On a phone the rows become cards.
Code
import { useState } from 'react';
import { CreatorCell, DataTable, Money, ScoreRing, TierChip, type DataColumn, type DataSort } from '@ergasti/bricks';
import { creators, type Creator } from './sample-data';
const columns: DataColumn<Creator>[] = [
{ key: 'creator', label: 'Creator', sortKey: 'name', sortFirst: 'asc', render: (c) => <CreatorCell id={c.id} name={c.name} identity={c.identity} /> },
{ key: 'tier', label: 'Tier', render: (c) => <TierChip tier={c.tier} /> },
{ key: 'score', label: 'Score', sortKey: 'score', align: 'center', render: (c) => <ScoreRing value={c.score} /> },
{ key: 'orders', label: 'Orders', sortKey: 'orders', align: 'end', render: (c) => c.orders },
{ key: 'sales', label: 'Sales', sortKey: 'sales', align: 'end', render: (c) => <b><Money value={c.sales.toFixed(2)} compact /></b> },
];
function Sortable() {
const [sort, setSort] = useState<DataSort>({ key: 'sales', dir: 'desc' });
const rows = [...creators.slice(0, 6)].sort((a, b) => {
const key = sort.key as keyof Creator;
const [x, y] = [a[key], b[key]];
return (x > y ? 1 : x < y ? -1 : 0) * (sort.dir === 'asc' ? 1 : -1);
});
return <DataTable label="Creators" columns={columns} rows={rows} rowKey={(c) => c.id} sort={sort} onSort={setSort} onRowClick={() => {}} isDim={(c) => c.status === 'Removed'} />;
}Loading, empty and error
loading draws skeleton rows, an empty rows shows the empty text (with "Clear filters" when you pass onClearFilters), and error shows the message with Retry.
Code
import { CreatorCell, DataTable, Money, ScoreRing, TierChip, type DataColumn } from '@ergasti/bricks';
import { creators, type Creator } from './sample-data';
const columns: DataColumn<Creator>[] = [
{ key: 'creator', label: 'Creator', sortKey: 'name', sortFirst: 'asc', render: (c) => <CreatorCell id={c.id} name={c.name} identity={c.identity} /> },
{ key: 'tier', label: 'Tier', render: (c) => <TierChip tier={c.tier} /> },
{ key: 'score', label: 'Score', sortKey: 'score', align: 'center', render: (c) => <ScoreRing value={c.score} /> },
{ key: 'orders', label: 'Orders', sortKey: 'orders', align: 'end', render: (c) => c.orders },
{ key: 'sales', label: 'Sales', sortKey: 'sales', align: 'end', render: (c) => <b><Money value={c.sales.toFixed(2)} compact /></b> },
];
function States() {
return (
<div style={{ display: 'grid', gap: 20 }}>
<DataTable label="Loading" columns={columns} rows={[]} rowKey={(c) => c.id} loading loadingRows={3} />
<DataTable label="Empty" columns={columns} rows={[]} rowKey={(c) => c.id} onClearFilters={() => {}} />
<DataTable label="Error" columns={columns} rows={[]} rowKey={(c) => c.id} error="We could not load the creators." onRetry={() => {}} />
</div>
);
}Row selection
Give selection and the table adds checkboxes (and a select-all); each row's label names its checkbox.
Code
import { useState } from 'react';
import { CreatorCell, DataTable, Money, ScoreRing, TierChip, type DataColumn } from '@ergasti/bricks';
import { creators, type Creator } from './sample-data';
const columns: DataColumn<Creator>[] = [
{ key: 'creator', label: 'Creator', sortKey: 'name', sortFirst: 'asc', render: (c) => <CreatorCell id={c.id} name={c.name} identity={c.identity} /> },
{ key: 'tier', label: 'Tier', render: (c) => <TierChip tier={c.tier} /> },
{ key: 'score', label: 'Score', sortKey: 'score', align: 'center', render: (c) => <ScoreRing value={c.score} /> },
{ key: 'orders', label: 'Orders', sortKey: 'orders', align: 'end', render: (c) => c.orders },
{ key: 'sales', label: 'Sales', sortKey: 'sales', align: 'end', render: (c) => <b><Money value={c.sales.toFixed(2)} compact /></b> },
];
function Selectable() {
const [selected, setSelected] = useState<ReadonlySet<string | number>>(new Set([1]));
return (
<DataTable
label="Creators" columns={columns} rows={creators.slice(0, 4)} rowKey={(c) => c.id}
selection={{ selected, onChange: setSelected, rowLabel: (c) => c.name }}
footer={<small>{selected.size} selected</small>}
/>
);
}Header tips, muted cells and phone cards
tip draws a non-money header as a dotted term with a tip, and a sortable column keeps its sort button beside it ("Sort by Orders"). tone: 'muted' makes a cell 12px grey (a date, a secondary figure). Under 860px the rows become cards: the primary column spans the card with no label, and an inline column (a rank) shares its row. Narrow the window under 860px to see the cards.
Code
import { useState } from 'react';
import { CreatorCell, DataTable, Money, RankMedal, ScoreRing, TierChip, type DataColumn, type DataSort } from '@ergasti/bricks';
import { creators, type Creator } from './sample-data';
const columns: DataColumn<Creator>[] = [
{ key: 'creator', label: 'Creator', sortKey: 'name', sortFirst: 'asc', render: (c) => <CreatorCell id={c.id} name={c.name} identity={c.identity} /> },
{ key: 'tier', label: 'Tier', render: (c) => <TierChip tier={c.tier} /> },
{ key: 'score', label: 'Score', sortKey: 'score', align: 'center', render: (c) => <ScoreRing value={c.score} /> },
{ key: 'orders', label: 'Orders', sortKey: 'orders', align: 'end', render: (c) => c.orders },
{ key: 'sales', label: 'Sales', sortKey: 'sales', align: 'end', render: (c) => <b><Money value={c.sales.toFixed(2)} compact /></b> },
];
function TipsAndCards() {
const [sort, setSort] = useState<DataSort>({ key: 'sales', dir: 'desc' });
const ranked = creators.slice(0, 5);
const cols: DataColumn<Creator>[] = [
{ key: 'rank', label: '#', inline: true, width: '56px', render: (c) => <RankMedal rank={ranked.indexOf(c) + 1} /> },
{ key: 'creator', label: 'Creator', primary: true, render: (c) => <CreatorCell id={c.id} name={c.name} identity={c.identity} /> },
{ key: 'orders', label: 'Orders', tip: 'Orders placed with this creator’s coupon in the period, before returns.', sortKey: 'orders', align: 'end', render: (c) => c.orders },
{ key: 'score', label: 'Score', tip: 'TRNDR’s 0–100 rating of a creator.', align: 'center', render: (c) => <ScoreRing value={c.score} /> },
{ key: 'sales', label: 'Sales', sortKey: 'sales', align: 'end', render: (c) => <b><Money value={c.sales.toFixed(2)} compact /></b> },
{ key: 'status', label: 'Status', tone: 'muted', render: (c) => c.status },
];
return <DataTable label="Top creators" columns={cols} rows={ranked} rowKey={(c) => c.id} sort={sort} onSort={setSort} />;
}Clickable rows without the chevron
chevron={false} keeps rows opening on click, Enter and Space but drops the trailing › column, for a summary table inside a card. By default a table with onRowClick shows the ›.
Code
import { CreatorCell, DataTable, Money, ScoreRing, TierChip, type DataColumn } from '@ergasti/bricks';
import { creators, type Creator } from './sample-data';
const columns: DataColumn<Creator>[] = [
{ key: 'creator', label: 'Creator', sortKey: 'name', sortFirst: 'asc', render: (c) => <CreatorCell id={c.id} name={c.name} identity={c.identity} /> },
{ key: 'tier', label: 'Tier', render: (c) => <TierChip tier={c.tier} /> },
{ key: 'score', label: 'Score', sortKey: 'score', align: 'center', render: (c) => <ScoreRing value={c.score} /> },
{ key: 'orders', label: 'Orders', sortKey: 'orders', align: 'end', render: (c) => c.orders },
{ key: 'sales', label: 'Sales', sortKey: 'sales', align: 'end', render: (c) => <b><Money value={c.sales.toFixed(2)} compact /></b> },
];
function NoChevron() {
return <DataTable label="Creators" columns={columns} rows={creators.slice(0, 4)} rowKey={(c) => c.id} onRowClick={() => {}} chevron={false} />;
}Tight rows
density="tight" draws the body cells with 9px top and bottom padding instead of 12 (the PR Creators list), for long lists; the head row and the phone cards keep their spacing.
Code
import { CreatorCell, DataTable, Money, ScoreRing, TierChip, type DataColumn } from '@ergasti/bricks';
import { creators, type Creator } from './sample-data';
const columns: DataColumn<Creator>[] = [
{ key: 'creator', label: 'Creator', sortKey: 'name', sortFirst: 'asc', render: (c) => <CreatorCell id={c.id} name={c.name} identity={c.identity} /> },
{ key: 'tier', label: 'Tier', render: (c) => <TierChip tier={c.tier} /> },
{ key: 'score', label: 'Score', sortKey: 'score', align: 'center', render: (c) => <ScoreRing value={c.score} /> },
{ key: 'orders', label: 'Orders', sortKey: 'orders', align: 'end', render: (c) => c.orders },
{ key: 'sales', label: 'Sales', sortKey: 'sales', align: 'end', render: (c) => <b><Money value={c.sales.toFixed(2)} compact /></b> },
];
function Tight() {
return <DataTable label="Creators" columns={columns} rows={creators.slice(0, 5)} rowKey={(c) => c.id} density="tight" onRowClick={() => {}} />;
}Compact head
With selection, the select-all checkbox's 28px hit area makes the head row 53px; headDensity="compact" lets the hit area hang over the cell padding instead, so the head row is 45px as in the PR Portal mock (touch screens keep the 44px hit area).
Code
import { useState } from 'react';
import { CreatorCell, DataTable, Money, ScoreRing, TierChip, type DataColumn } from '@ergasti/bricks';
import { creators, type Creator } from './sample-data';
const columns: DataColumn<Creator>[] = [
{ key: 'creator', label: 'Creator', sortKey: 'name', sortFirst: 'asc', render: (c) => <CreatorCell id={c.id} name={c.name} identity={c.identity} /> },
{ key: 'tier', label: 'Tier', render: (c) => <TierChip tier={c.tier} /> },
{ key: 'score', label: 'Score', sortKey: 'score', align: 'center', render: (c) => <ScoreRing value={c.score} /> },
{ key: 'orders', label: 'Orders', sortKey: 'orders', align: 'end', render: (c) => c.orders },
{ key: 'sales', label: 'Sales', sortKey: 'sales', align: 'end', render: (c) => <b><Money value={c.sales.toFixed(2)} compact /></b> },
];
function CompactHead() {
const [selected, setSelected] = useState<ReadonlySet<string | number>>(new Set([1]));
return (
<DataTable
label="Creators" columns={columns} rows={creators.slice(0, 3)} rowKey={(c) => c.id} headDensity="compact"
selection={{ selected, onChange: setSelected, rowLabel: (c) => c.name }}
/>
);
}Some rows do not open
With onRowClick, isRowClickable turns rows off one by one (an anonymous join request with no drawer): no focus stop, no hover, no ›, and click, Enter and Space do nothing. In cards mode renderCard gets { clickable }.
Code
import { CreatorCell, DataTable, Money, ScoreRing, TierChip, type DataColumn } from '@ergasti/bricks';
import { creators, type Creator } from './sample-data';
const columns: DataColumn<Creator>[] = [
{ key: 'creator', label: 'Creator', sortKey: 'name', sortFirst: 'asc', render: (c) => <CreatorCell id={c.id} name={c.name} identity={c.identity} /> },
{ key: 'tier', label: 'Tier', render: (c) => <TierChip tier={c.tier} /> },
{ key: 'score', label: 'Score', sortKey: 'score', align: 'center', render: (c) => <ScoreRing value={c.score} /> },
{ key: 'orders', label: 'Orders', sortKey: 'orders', align: 'end', render: (c) => c.orders },
{ key: 'sales', label: 'Sales', sortKey: 'sales', align: 'end', render: (c) => <b><Money value={c.sales.toFixed(2)} compact /></b> },
];
function SomeRowsNotClickable() {
return <DataTable label="Join requests" columns={columns} rows={creators.slice(0, 4)} rowKey={(c) => c.id} onRowClick={() => {}} isRowClickable={(c) => c.id % 2 === 0} />;
}Cards in fixed columns
mode="cards" with cardColumns={3} draws three cards a row (two at 1240px and under, one at 720px), and keeps the table's loading, empty and error states; switch loading to see the skeleton cards in the same columns.
Code
import { useState } from 'react';
import { CreatorCell, DataTable, Money, ScoreRing, TierChip, type DataColumn } from '@ergasti/bricks';
import { creators, type Creator } from './sample-data';
const columns: DataColumn<Creator>[] = [
{ key: 'creator', label: 'Creator', sortKey: 'name', sortFirst: 'asc', render: (c) => <CreatorCell id={c.id} name={c.name} identity={c.identity} /> },
{ key: 'tier', label: 'Tier', render: (c) => <TierChip tier={c.tier} /> },
{ key: 'score', label: 'Score', sortKey: 'score', align: 'center', render: (c) => <ScoreRing value={c.score} /> },
{ key: 'orders', label: 'Orders', sortKey: 'orders', align: 'end', render: (c) => c.orders },
{ key: 'sales', label: 'Sales', sortKey: 'sales', align: 'end', render: (c) => <b><Money value={c.sales.toFixed(2)} compact /></b> },
];
function CardColumns() {
const [loading, setLoading] = useState(false);
return (
<div style={{ display: 'grid', gap: 12 }}>
<label><input type="checkbox" checked={loading} onChange={(event) => setLoading(event.target.checked)} /> Loading</label>
<DataTable label="Creators" mode="cards" cardColumns={3} columns={columns} rows={loading ? [] : creators.slice(0, 6)} rowKey={(c) => c.id} loading={loading} loadingRows={3}
renderCard={(c) => <article style={{ padding: 16, border: '1px solid var(--line)', borderRadius: 18 }}><b>{c.name}</b></article>} />
</div>
);
}Props
Prop
Type
Labels
Every word this component draws, in both languages. Override one per component and language with BricksProvider labels under the key dataTable, or with the component's own prop where it has one. A {name} is a value the component fills in.
| Key | English | Arabic |
|---|---|---|
nothing | Nothing matches these filters. | مفيش حاجة مطابقة للفلاتر دي. |
clear | Clear filters | امسح الفلاتر |
retry | Try again | جرّب تاني |
all | Select all | اختار الكل |
one | Select {name} | اختار {name} |
loading | Loading… | جارٍ التحميل… |
sortBy | Sort by {c} | رتّب حسب {c} |
Design guidance
How the BRICKS design system uses DataTable. Written in docs/content/components/DataTable.md; the props above are read from the code, which wins where the two disagree.
The one list engine for every table in both dashboards: a real <table> with sortable headers, rows that open a drawer, selection, loading, empty and error states, and stacked cards on phones; use it for any list of records.
DataTable is the v3 mock's .tbl. It sits in a bordered wrapper (radius 18) with a soft uppercase head row, renders each column through your render, and is fully controlled: sort / onSort and the page live with the screen (usually useListState). Rows with onRowClick open on click, Enter or Space and get a trailing ›; a control inside a row acts on its own and never opens the row. Under 860px every row becomes a stacked card labelled by its column names; mode="cards" draws rows with renderCard in an auto-fill grid instead (Find creators).
Anatomy
- Wrapper (
.kit-dt-wrap): 1px--line, radius 18,--card, horizontal scroll when needed. - Head (
thead,--tbl-head): uppercase labels; sortable ones are buttons with ↕ / ↑ / ↓ and thethcarriesaria-sort. A money column (figure) adds itsMoneyNote"?"; atipcolumn draws the label as aTermwith an arrow-only sort button beside it. - Select-all (with
selection): a checkbox in the first head cell. - Rows (
tbody tr): cells per column (numfor end-aligned figures,midfor centred rings,mutedfor 12px grey). - Chevron cell (clickable rows): "›", mirrored in RTL.
- Footer (
.kit-dt-foot, 14px below): thePageror a count. - States: skeleton rows, an error block with "Try again", an empty block with "Clear filters".
Variants
| Prop | Value | Look | When |
|---|---|---|---|
mode | 'table' (default) | Table, stacked cards < 860px | Every list |
mode | 'cards' + renderCard | Auto-fill grid of cards (min 300px) | Find creators |
density | 'default' | 12px cell padding | Most tables |
density | 'tight' | 9px top/bottom (60px two-line creator row) | Creators lists |
headDensity | 'default' | Head row sized by the checkbox hit area (53px with selection) | — |
headDensity | 'compact' | 45px head with or without selection | The mock's selectable lists |
chevron | true (default) / false | Trailing › on clickable rows, or none | false when a caption says "Click a brand…" |
column align | 'start' / 'end' / 'center' | Text, tabular figures, centred rings | — |
column tone | 'default' / 'muted' | Normal or 12px grey | Dates, secondary figures |
Phone layout (viewport under 860px)
Each row becomes a stacked card: the primary column (default: the first) spans the card without its label, the other cells show their column name from data-label (a string label or cardLabel), an inline column (a rank medal) shares the primary cell's row, and the chevron stays at the end. It is a viewport media query, not a container query, so a narrow Card on a wide screen still shows the table; this 960px preview cannot show it. The Tables and lists card renders a full list section at 390px, where the stacked cards appear.
States
| State | Trigger | Look |
|---|---|---|
| Default | rows | Table |
| Hover | pointer on a clickable row | --row-hover background, pointer |
| Focus-visible | Tab to a row | Inset 2px --rasp outline and the --row-hover background (sort buttons use --focus-ring) |
| Not clickable row | isRowClickable(row) === false | No tab stop, hover, chevron or action |
| Selected | key in selection.selected | --rasp-50 row |
| Dimmed | isDim(row) | --soft row, text readable |
| Sorted | sort.key === column.sortKey | ↑ / ↓ arrow, aria-sort |
| Loading first page | loading and no rows | loadingRows (5) skeleton rows (cards mode: skeleton cards) |
| Loading next page | loading with rows | Rows stay, aria-busy |
| Empty | no rows, not loading | "Nothing matches these filters." + "Clear filters" (with onClearFilters), or empty. The state replaces the whole table, header and bordered frame included (40px padding, centred): put the DataTable in a Card so the message sits inside the card, as the screens do |
| Error | error | role="alert" block + "Try again" (with onRetry), also without the table frame (see Empty) |
Types
DataColumn<T>: key (required), label (required, ReactNode), render (required), cardLabel, sortKey, sortFirst ('asc' | 'desc', default 'desc' on first click), align, width, figure (a MoneyFigureKey: the header "?"), tip (header Term), tone ('default' | 'muted'), primary (spans the phone card, default the first column), inline (shares the primary row on phones, e.g. a rank medal).
DataSort (sort): { key, dir } currently applied. Selection<T> (selection): { selected: ReadonlySet<string | number>; onChange; rowLabel: (row) => string }.
Usage
My creators with a toolbar and pager, driven by useListState:
const fetcher = useMemo(() => listFetcher<Creator>(client, '/brand/creators', { chipParam: 'status' }), [client]);
const list = useListState<Creator>({ namespace: 'mine', defaults: { chip: 'all', sort: 'sales', dir: 'desc' }, fetcher });
<Card>
<ListToolbar
search={{ value: list.query.q, onChange: (q) => list.set({ q }), placeholder: 'Search by name or coupon' }}
chips={{ label: 'Status', value: list.query.chip, onChange: (chip) => list.set({ chip }),
options: [{ value: 'all', label: 'All' }, { value: 'active', label: 'Active' }, { value: 'paused', label: 'Paused' }] }}
reset={{ active: list.query.q !== '' || list.query.chip !== 'all', onReset: list.reset }} />
<DataTable label="My creators" density="tight" rows={list.rows} rowKey={(c) => c.id}
sort={{ key: list.query.sort, dir: list.query.dir }} onSort={(s) => list.set({ sort: s.key, dir: s.dir })}
onRowClick={(c) => openCreator(c.id)} loading={list.loading} error={list.error?.message ?? null}
onRetry={list.retry} onClearFilters={list.reset}
columns={[
{ key: 'creator', label: 'Creator', primary: true, sortKey: 'name', sortFirst: 'asc', render: (c) => <CreatorCell id={c.id} name={c.name} identity={c.identity} /> },
{ key: 'tier', label: 'Tier', sortKey: 'tier', render: (c) => <TierChip tier={c.tier} /> },
{ key: 'score', label: 'Score', tip: 'How well this creator sells on TRNDR', align: 'center', sortKey: 'score', render: (c) => <ScoreRing value={c.score} /> },
{ key: 'followers', label: 'Followers', align: 'center', sortKey: 'fol', render: (c) => <FollowersCell followers={c.followers} /> },
{ key: 'sales', label: 'Sales', align: 'end', sortKey: 'sales', render: (c) => <Money value={c.sales} /> },
{ key: 'joined', label: 'Joined', tone: 'muted', render: (c) => c.joinedOn },
{ key: 'status', label: 'Status', render: (c) => <StatusPill status={c.status} /> },
]}
footer={<Pager page={list.page} lastPage={list.lastPage} total={list.total} perPage={10} loading={list.loading}
label="My creators" onPage={(page) => list.set({ page })} />} />
</Card>Selectable rows with a bulk bar:
<>
<BulkBar count={selected.size}>
<Button size="sm">Reject</Button>
<Button size="sm" variant="ink">Approve</Button>
</BulkBar>
<DataTable label="Join requests" headDensity="compact" rows={requests} rowKey={(r) => r.id} columns={columns}
selection={{ selected, onChange: setSelected, rowLabel: (r) => r.name }} isRowClickable={(r) => !r.anonymous} onRowClick={openRequest} />
</>Cards mode (Find creators):
function FindCreators({ creators }: { creators: FindCreator[] }) {
const [shown, setShown] = useState<number | null>(null);
return (
<DataTable label="Find creators" mode="cards" columns={[]} rows={creators} rowKey={(c) => c.id}
onRowClick={(c) => setShown(c.id)}
renderCard={(c) => <FindCreatorCard creator={c} invited={false} onOpen={() => setShown(c.id)} onInvite={() => console.log('invite', c.id)} />}
footer={<Pager page={1} lastPage={2} total={12} perPage={8} loading={false} label="Find creators" onPage={() => {}} />} />
);
}Where it appears
- Brand › Creators › My creators, Join requests, Invitations; Brand › Coupons; Brand › Payments › Commissions orders and Past payouts; Brand › Analytics › Best creators and Best-selling products; Brand › Find creators (cards mode).
- PR Portal › Creators, Brands, Approvals, Gift stock, Gift analytics "By brand" (no chevron), Affiliate programs › Campaigns. The Fraud cases table is a library-only screen (not in the v3 mock).
- Screens: Creators, Coupons, Payments › Wallet, Analytics, Find creators, PR · Creators, PR · Brands, PR · Approvals, PR · Gift stock, PR · Gift analytics, PR · Affiliate programs.
Guidelines
Do
- Keep sort and page in the screen (
useListState), send them to the server, pass back one page. - Mark the creator/product column
primary; give figuresalign: 'end'and money columnsfigure. - Pass
onClearFiltersso an empty filtered list has a way out.
Don't
- Don't sort or page in the browser for server lists.
- Don't put a second clickable target that duplicates
onRowClick; controls inside rows should do something different. - Don't exceed ~8 columns; move detail into the row's drawer.
RTL and Arabic
- Columns follow the page direction;
align: 'end'puts figures on the left in Arabic; the › chevron mirrors. - Phone cards use
data-labelfrom string labels orcardLabel: give ArabiccardLabels when labels are nodes.
Tokens
--line, --card, --tbl-head, --row-hover, --rasp-50, --rasp-100, --rasp, --soft, --ink, --ink-3, --bad, --focus-ring, --r-lg, --card-min, --min-touch-target.
Accessibility
- A real
<table>named bylabel;th scope="col"; sortable headers hold a<button>and thethcarriesaria-sort(ascending / descending / none). A tipped header (tip) keeps itsTermbutton and gets a separate arrow-only sort button named "Sort by {column}". - Clickable rows are
tabIndex=0and open with Enter or Space (Space does not scroll the page); events that start on a control inside the row are left to that control. A row turned off byisRowClickablehas no tab stop. - Focus: a clickable row shows an inset 2px
--raspoutline (outline-offset: -2px) and the hover background; under 860px the background moves to the row card. Sort buttons use the shared--focus-ring. - Checkboxes are named "Select {rowLabel}" and "Select all"; their hit area is 28px on desktop and 44px on touch screens (≤1024px).
- States: errors are
role="alert"; while loading the table hasaria-busy. The cards-mode skeleton carries visually hidden "Loading…" text, and its skeleton cards arearia-hidden. - The trailing › and the skeleton rows are
aria-hidden.
Found in the source
- Roles in the markup:
alert. - ARIA attributes set:
aria-busy,aria-hidden,aria-label,aria-sort. - Its tests cover: “is a real labelled table with a header row and one row per item”; “sortable headers are buttons with ↕/↑/↓; aria-sort on the th; a new column starts at its first order, the same one flips”; “clickable rows: tabIndex 0, click / Enter / Space open, a trailing › cell; inner controls do not open the row”; “loading: skeleton rows under the real head (aria-busy); later pages keep their rows while loading”; “rows stay clickable by mouse and keyboard, with no › column (header, rows or loading rows)”; “a non-clickable row: no tabIndex, no click class, no chevron, and click / Enter / Space do nothing; others open”.
Read from the component's source and tests. See Accessibility for the patterns the library follows.
Related
ListToolbar: search, chips, selects, sort above it.Pager: its footer.BulkBar/PrBulkBar: actions for selected rows.RowList: the deprecated 0.1.x list.DetailsDrawer/Drawer: what a row opens.
See also: MoneyNote · Button · Term · RankMedal · CreatorCell · ScoreRing · Money · CopyLink · FilterChips
Source
src/kit/patterns/DataTable.tsx (line 129) on GitHub.