component
Table
Rows of the same kind of thing, side by side in columns, like the accounting app's payments. No box, a hairline between rows.
| URSSAF31 OctQ3 contributions | €1,284 |
|---|---|
| Income tax15 NovInstalment 2 of 3estimate | €640 |
| URSSAF31 JanQ4 contributionsestimate | €1,310 |
With a caption| URSSAF31 OctQ3 contributions | €1,284 |
|---|---|
| Income tax15 NovInstalment 2 of 3estimate | €640 |
| URSSAF31 JanQ4 contributionsestimate | €1,310 |
Rows as links| Payment | Amount |
|---|---|
| URSSAF31 OctQ3 contributions | €1,284 |
| Income tax15 NovInstalment 2 of 3estimate | €640 |
| URSSAF31 JanQ4 contributionsestimate | €1,310 |
With column headersimport { Table } from 'rost/components/table/Table'
import { TableRow } from 'rost/components/table-row/TableRow'
import { TableItem } from 'rost/components/table-item/TableItem'
import { Checkbox } from 'rost/components/checkbox/Checkbox'
<Table caption="What to pay, and when">
{payments.map((p) => (
<TableRow key={p.id} href={`/payments/${p.id}`}>
<TableItem header="row" leading={<Badge status="positive">URSSAF</Badge>} description={p.label}>
{p.date}
</TableItem>
<TableItem numeric>{eur(p.amount)}</TableItem>
</TableRow>
))}
</Table>
// Sorted by a column, with rows to pick
<Table
aria-label="Invoices"
head={
<TableRow>
<TableItem header="column">
<Checkbox aria-label="Select all" checked={allPicked} indeterminate={somePicked} onCheckedChange={toggleAll} />
</TableItem>
<TableItem header="column" sort={by === 'client' ? dir : 'none'} onSort={() => sortBy('client')}>Client</TableItem>
<TableItem header="column" numeric sort={by === 'amount' ? dir : 'none'} onSort={() => sortBy('amount')}>Amount</TableItem>
</TableRow>
}
>
{sorted.map((inv) => (
<TableRow key={inv.id} selected={picked.has(inv.id)}>
<TableItem>
<Checkbox aria-label={`Select ${inv.client}`} checked={picked.has(inv.id)} onCheckedChange={(on) => pick(inv.id, on)} />
</TableItem>
<TableItem header="row">{inv.client}</TableItem>
<TableItem numeric>{eur(inv.amount)}</TableItem>
</TableRow>
))}
</Table> src/components/table/Table.tsx
import type { ReactNode, TableHTMLAttributes } from 'react'
import './table.css'
export interface TableProps extends Omit<TableHTMLAttributes<HTMLTableElement>, 'children'> {
/** What the table is, drawn above the rows. Without one, give the table an `aria-label`. */
readonly caption?: ReactNode
/** A TableRow of column headers, for the `<thead>`. */
readonly head?: ReactNode
/** The TableRows, for the `<tbody>`. */
readonly children?: ReactNode
}
const b = 'rost-table'
/**
* Rows of the same kind of thing, in columns. A real `<table>` with no box of
* its own: the rows draw the hairlines. Built from contracts/table.contract.yaml.
*/
export function Table({ caption, head, children, className, ...rest }: TableProps) {
return (
<table className={[b, className].filter(Boolean).join(' ')} {...rest}>
{caption && <caption className={`${b}__caption`}>{caption}</caption>}
{head && <thead className={`${b}__head`}>{head}</thead>}
<tbody className={`${b}__body`}>{children}</tbody>
</table>
)
}
The source for everything on this page: contracts/table.contract.yaml (opens in a new tab). The CSS, the docs and the checks in each app are built from it.
# yaml-language-server: $schema=../schema/component-contract.schema.json
schemaVersion: 2
id: table
name: Table
kind: component
status: review
summary: Rows of the same kind of thing, side by side in columns, like the accounting app's payments. No box, a hairline between rows.
category: display
related: [ table-row, table-item, list-item ]
source:
tool: figma
fileKey: 1Zy0wiWKXQAvsfDBX3KR0d
nodeId: "527:596"
url: https://www.figma.com/design/1Zy0wiWKXQAvsfDBX3KR0d/UI-Kit-v01?node-id=527-596
extractedAt: "2026-10-30"
extractedBy: hand
frozenAt: "2026-10-30"
props:
caption: { type: slot, notes: "Optional, what the table is: \"What to pay, and when\". Drawn above the rows and read first by screen readers. Without one, give the table an `aria-label` or point `aria-labelledby` at the heading above it." }
head: { type: slot, notes: "Optional, a TableRow of column headers (TableItem with `header=\"column\"`). It goes in the `<thead>`. Leave it out when the rows explain themselves, as the accounting app's do." }
rows: { type: slot, notes: "The TableRows. In React, the children. They go in the `<tbody>`." }
elements:
root:
notes: "A real `<table>`. It has no surface of its own: no box, no fill. The rows draw the lines."
styles:
width: { value: 100%, untokenised: "As wide as where it sits." }
border-collapse: { value: collapse, assert: false, notes: "So a row's hairline is drawn; a `<tr>` only has borders when they collapse." }
font-family: { token: font-family/base, value: "'General Sans Variable'" }
font-weight: { token: typography/paragraph/font-weight/regular, value: "400" }
font-size: { token: typography/paragraph/font-size, value: 14px }
line-height: { token: typography/paragraph/line-height, value: 20px }
letter-spacing: { token: typography/paragraph/letter-spacing, value: 0px }
color: { token: non-interactive/foreground/primary, value: "#ededed" }
caption:
optional: true
notes: "The `<caption>`, above the rows, lined up with the text in the first column."
styles:
caption-side: { value: top, assert: false }
text-align: { value: left, assert: false }
padding-left: { token: spacing/gap/small-medium, value: 12px }
padding-right: { token: spacing/gap/small-medium, value: 12px }
padding-bottom: { token: spacing/gap/small, value: 8px }
font-weight: { token: typography/paragraph/font-weight/medium, value: "500" }
color: { token: non-interactive/foreground/primary, value: "#ededed" }
head:
optional: true
notes: "The `<thead>`. Only there when `head` is."
styles:
vertical-align: { value: bottom, assert: false }
body:
notes: "The `<tbody>` with the rows."
styles:
vertical-align: { value: middle, assert: false }
guidance:
status: agreed
use:
- title: Data read across
text: "Several things of the same kind with the same few facts each, read across: payments with a date, what they're for and an amount."
show: with a caption
- title: Columns that mean something
text: "When the columns mean something: an amount in the same place on every row, so the eye runs down them."
show: with column headers
avoid:
- title: One fact each
text: A list of things to pick or go to, one fact each. That's **ListItem**.
- title: Laying out a page
text: Laying out a page or a form. A table is for data.
show: with a caption
- title: Too many columns
text: "More columns than fit on a phone. Two or three is right: put the rest in the row's description, the way the accounting app puts \"leaves €4,210\" under the date."
show: with column headers
behaviour: |-
The table draws nothing itself. Each TableRow draws a hairline under it, the last one too, so the table has an end. Rows that are links or can be picked react to the pointer; the others don't.
Sorting: give a column header `sort` and `onSort`, and its words become a button with an arrow on the sorted column. The sorting itself is the app's: Rost draws the header and says which way it's sorted.
Picking several rows: a Checkbox in each row's first cell, named for its row ("Select Client One"), and the row `selected` while it's ticked. A Checkbox in the first column header picks them all; it's `indeterminate` while only some are picked. A row that's a link or a button already uses its header cell, so a table either picks rows with checkboxes or opens them, not both.
accessibility:
element: "a `<table>` with a `<caption>`, a `<thead>` when there are column headers and a `<tbody>`. Each row's first cell is usually its header (`<th scope=\"row\">`), so a screen reader names the row when it reads an amount. A sorted column header has `aria-sort` (ascending or descending), so a screen reader says how the table is ordered; the others have `aria-sort=\"none\"`."
name: "the `caption`. Without one, an `aria-label` or `aria-labelledby` on the table."
keyboard: "nothing of its own. A row that's a link or a button is one Tab stop, through its header cell. A sortable column header is a button: Tab reaches it, Enter or Space sorts. A row's Checkbox is its own Tab stop."
focus: "TableRow's focus ring, on the whole row."
content: "A caption in sentence case, a few words. Column headers are one or two words."
Install
npx github:Runceanu/rost add table It lands in src/rost/table/, with what it needs and its contract. Install has the rest.
When to use
Data read across
Several things of the same kind with the same few facts each, read across: payments with a date, what they're for and an amount.
Columns that mean something
When the columns mean something: an amount in the same place on every row, so the eye runs down them.
When not to use
One fact each
A list of things to pick or go to, one fact each. That's ListItem.
Laying out a page
Laying out a page or a form. A table is for data.
Too many columns
More columns than fit on a phone. Two or three is right: put the rest in the row's description, the way the accounting app puts "leaves €4,210" under the date.
Behaviour
The table draws nothing itself. Each TableRow draws a hairline under it, the last one too, so the table has an end. Rows that are links or can be picked react to the pointer; the others don't.
Sorting: give a column header sort and onSort, and its words become a button with an arrow on the sorted column. The sorting itself is the app's: Rost draws the header and says which way it's sorted.
Picking several rows: a Checkbox in each row's first cell, named for its row ("Select Client One"), and the row selected while it's ticked. A Checkbox in the first column header picks them all; it's indeterminate while only some are picked. A row that's a link or a button already uses its header cell, so a table either picks rows with checkboxes or opens them, not both.
Accessibility
- Element
a
<table>with a<caption>, a<thead>when there are column headers and a<tbody>. Each row's first cell is usually its header (<th scope="row">), so a screen reader names the row when it reads an amount. A sorted column header hasaria-sort(ascending or descending), so a screen reader says how the table is ordered; the others havearia-sort="none". - Name
the
caption. Without one, anaria-labeloraria-labelledbyon the table. - Keyboard
nothing of its own. A row that's a link or a button is one Tab stop, through its header cell. A sortable column header is a button: Tab reaches it, Enter or Space sorts. A row's Checkbox is its own Tab stop.
- Focus
TableRow's focus ring, on the whole row.
Content
A caption in sentence case, a few words. Column headers are one or two words.
Props
| Prop | Type | Values | Default |
|---|---|---|---|
caption | slot | | |
head | slot | | |
rows | slot | | |
Values
Straight from the contract. Each value sits next to its token, because six tokens here all come out as #3a3a3a and the colour alone can't tell you which one is right.
Never changes
root
-
font-family'General Sans Variable'font-family/base -
font-weight400typography/paragraph/font-weight/regular -
font-size14pxtypography/paragraph/font-size -
line-height20pxtypography/paragraph/line-height -
letter-spacing0pxtypography/paragraph/letter-spacing -
color#ededednon-interactive/foreground/primary
width100% · border-collapsecollapse
caption
-
padding-left12pxspacing/gap/small-medium -
padding-right12pxspacing/gap/small-medium -
padding-bottom8pxspacing/gap/small -
font-weight500typography/paragraph/font-weight/medium -
color#ededednon-interactive/foreground/primary
caption-sidetop · text-alignleft
head
vertical-alignbottom
body
vertical-alignmiddle
Part of Table
TableItem
One cell of a TableRow. Its content with an optional line under it, and leading and trailing slots for a Badge or an icon.
| labelLabelDescriptionlabel |
None · Not numeric · None| labelLabelDescriptionlabel |
None · Numeric · None| labelLabelDescriptionlabel |
|---|
Row · Not numeric · None| labelLabelDescriptionlabel |
|---|
Row · Numeric · None| labelLabelDescriptionlabel |
|---|
Column · Not numeric · None| labelLabelDescriptionlabel |
|---|
Column · Numeric · NoneColumn · Not numeric · AscendingColumn · Not numeric · Descendingimport { TableItem } from 'rost/components/table-item/TableItem'
<TableItem header="row" leading={<Badge status="warning">Income tax</Badge>} trailing={<Badge>estimate</Badge>} description="Instalment 2 of 3">
15 Nov
</TableItem>
<TableItem numeric description="→ €1,310 projected">{eur(amount)}</TableItem> src/components/table-item/TableItem.tsx
import { useContext, type ReactNode, type TdHTMLAttributes } from 'react'
import { RowAction } from '../table-row/TableRow'
import './table-item.css'
export interface TableItemProps extends TdHTMLAttributes<HTMLTableCellElement> {
/** `row` names its row (`<th scope="row">`) and holds the row's link; `column` is a column header. */
readonly header?: 'row' | 'column'
/** For amounts: on the right, on one line. */
readonly numeric?: boolean
/** A line under the content, in the quieter colour. */
readonly description?: ReactNode
/** Before the content: a Badge, or an icon drawn with `currentColor`. */
readonly leading?: ReactNode
/** After the content: a Badge, or an icon drawn with `currentColor`. */
readonly trailing?: ReactNode
/** On a column header: how the table is sorted by this column. */
readonly sort?: 'none' | 'ascending' | 'descending'
/** On a column header: makes its words a button that sorts by this column. */
readonly onSort?: () => void
/** What the cell says. */
readonly children?: ReactNode
}
const b = 'rost-table-item'
/**
* One cell of a TableRow, with leading and trailing slots. A `<td>`, or a
* `<th>` when it's a header. Built from contracts/table-item.contract.yaml.
*/
export function TableItem({ header, numeric = false, sort, onSort, description, leading, trailing, children, className, ...rest }: TableItemProps) {
const { href, onSelect, selected } = useContext(RowAction)
const sortable = header === 'column' && onSort !== undefined
const cls = [b, header && `${b}--header-${header}`, numeric && `${b}--numeric`, header === 'column' && `${b}--sort-${sort ?? 'none'}`, className].filter(Boolean).join(' ')
const content = (
<span className={`${b}__content`}>
{leading && <span className={`${b}__leading`}>{leading}</span>}
<span className={`${b}__text`}>
<span className={`${b}__label`}>{children}</span>
{description && <span className={`${b}__description`}>{description}</span>}
</span>
{trailing && <span className={`${b}__trailing`}>{trailing}</span>}
</span>
)
// Only the row's header cell carries the row's link or button.
const cover = <span className={`${b}__cover`} />
const inner = sortable ? <button type="button" className={`${b}__sort`} onClick={onSort}>{content}<span className={`${b}__sort-icon`} aria-hidden="true" /></button>
: header !== 'row' ? content
: href !== undefined ? <a className={`${b}__action`} href={href} aria-current={selected || undefined}>{content}{cover}</a>
: onSelect ? <button type="button" className={`${b}__action`} aria-pressed={selected} onClick={onSelect}>{content}{cover}</button>
: content
if (header) return <th scope={header === 'row' ? 'row' : 'col'} aria-sort={sortable ? sort ?? 'none' : undefined} className={cls} {...rest}>{inner}</th>
return <td className={cls} {...rest}>{inner}</td>
}
The source for everything on this page: contracts/table-item.contract.yaml (opens in a new tab). The CSS, the docs and the checks in each app are built from it.
# yaml-language-server: $schema=../schema/component-contract.schema.json
schemaVersion: 2
id: table-item
name: TableItem
partOf: table
kind: component
status: review
summary: One cell of a TableRow. Its content with an optional line under it, and leading and trailing slots for a Badge or an icon.
category: display
related: [ table, table-row, badge ]
source:
tool: figma
fileKey: 1Zy0wiWKXQAvsfDBX3KR0d
nodeId: "527:126"
url: https://www.figma.com/design/1Zy0wiWKXQAvsfDBX3KR0d/UI-Kit-v01?node-id=527-126
extractedAt: "2026-10-30"
extractedBy: hand
frozenAt: "2026-10-30"
props:
content: { type: slot, notes: "What the cell says. In React, the children." }
description: { type: slot, notes: "Optional, a line under the content in the quieter colour: what a payment is for, or what an amount would be." }
leading: { type: slot, notes: "Optional, before the content: a Badge, or a 20px icon drawn with `currentColor`. The accounting app puts the tax a payment is for here." }
trailing: { type: slot, notes: "Optional, after the content: a Badge or an icon. The accounting app marks an estimate here." }
header:
type: enum
values: [ None, Row, Column ]
default: None
notes: "None is a data cell, a `<td>`. Row is the cell that names its row, a `<th scope=\"row\">`, in medium weight; in a row with `href` or `onSelect` it holds the link or button. Column is a column header in the table's `head`, a `<th scope=\"col\">`, in the smaller label size."
numeric: { type: boolean, default: false, notes: "For amounts: lined up on the right and kept on one line, so a minus sign never breaks off. Its column header should be numeric too." }
sort:
type: enum
values: [ None, Ascending, Descending ]
default: None
notes: "Only on a column header. With `onSort` in React the header's words become a button that sorts by its column, with `aria-sort` on the `<th>`. Ascending shows an arrow up, Descending an arrow down; None shows no arrow, so only the sorted column is marked."
states: [ Default, Highlighted, SelectedRow, SortHover, SortFocus ]
stateSelectors:
Highlighted: ":is(.rost-table-row--selected *, .rost-table-row:has(.rost-table-item__action:is(:hover, :active, :focus-visible)) *)"
SelectedRow: ":is(.rost-table-row--selected > :first-child)"
SortHover: ":has(.rost-table-item__sort:hover)"
SortFocus: ":has(.rost-table-item__sort:focus-visible)"
elements:
root:
notes: "A `<td>` or a `<th>`. 12px at the sides, as ListItem, so the text lines up with a ListItem's above or below the table."
styles:
padding-top: { token: spacing/gap/small, value: 8px }
padding-bottom: { token: spacing/gap/small, value: 8px }
padding-left: { token: spacing/gap/small-medium, value: 12px }
padding-right: { token: spacing/gap/small-medium, value: 12px }
text-align: { value: left, assert: false }
font-weight: { value: inherit, assert: false, notes: "A `<th>` is bold in the browser; here the header's weight comes from `header`." }
action:
optional: true
notes: "Only in a row's header cell when the row has `href` or `onSelect`: an `<a>` or a `<button>` round the content. Nothing of its own shows; the row draws the states."
styles:
display: { value: block, assert: false }
width: { value: 100%, untokenised: "As wide as its cell." }
padding: { value: "0", assert: false }
background: { value: none, assert: false }
border: { value: none, assert: false }
color: { value: inherit, assert: false }
font: { value: inherit, assert: false }
text-align: { value: inherit, assert: false }
text-decoration: { value: none, assert: false }
cursor: { value: pointer, assert: false }
outline: { value: none, assert: false, notes: "The row draws the focus ring." }
cover:
optional: true
notes: "An empty layer inside the action, stretched over the whole row, so the pointer anywhere on the row hovers and presses the link."
styles:
position: { value: absolute, assert: false }
inset: { value: "0", assert: false }
sort:
optional: true
notes: "Only on a column header with `onSort`: a `<button>` round the header's words and the arrow, 4px apart. Its own look is taken away; it underlines on hover and takes the focus ring."
styles:
display: { value: inline-flex, assert: false }
align-items: { value: center }
gap: { token: spacing/gap/2xsmall, value: 4px }
padding: { value: "0", assert: false }
border: { value: none, assert: false }
border-radius: { token: spacing/radius/xsmall, value: 4px }
background: { value: none, assert: false }
color: { value: inherit, assert: false }
font: { value: inherit, assert: false }
text-align: { value: inherit, assert: false }
cursor: { value: pointer, assert: false }
outline: { value: none, assert: false }
sort-icon:
optional: true
notes: "Icon's arrow-up or arrow-down at 16px, as a mask in the header's colour."
styles:
display: { value: block, assert: false }
flex-shrink: { value: "0", assert: false }
width: { token: spacing/size/2xsmall, value: 16px }
height: { token: spacing/size/2xsmall, value: 16px }
background: { value: currentColor, assert: false }
mask-size: { value: 100% 100%, assert: false }
mask-repeat: { value: no-repeat, assert: false }
content:
notes: "Leading, the text and trailing, side by side."
styles:
display: { value: flex, assert: false }
align-items: { value: center }
gap: { token: spacing/gap/small, value: 8px }
leading:
optional: true
styles:
display: { value: flex, assert: false }
align-items: { value: center }
flex-shrink: { value: "0", assert: false }
text:
notes: The content over the description.
styles:
display: { value: flex, assert: false }
flex-direction: { value: column, assert: false }
gap: { token: spacing/gap/3xsmall, value: 2px }
min-width: { value: "0", assert: false }
label:
notes: "In the text colour, inherited from the Table."
styles:
overflow-wrap: { value: anywhere, assert: false }
description:
optional: true
styles:
font-weight: { token: typography/label/font-weight/regular, value: "400" }
font-size: { token: typography/label/font-size, value: 12px }
line-height: { token: typography/label/line-height, value: 14px }
letter-spacing: { token: typography/label/letter-spacing, value: 0px }
color: { token: table-item/sub-label, value: "#999999" }
trailing:
optional: true
styles:
display: { value: flex, assert: false }
align-items: { value: center }
flex-shrink: { value: "0", assert: false }
variants:
- when: { state: Highlighted }
elements:
description:
color: { token: table-item/highlighted/sub-label, value: "#ededed", notes: "Highlighted isn't something you set: a cell is highlighted when its row is selected, hovered, pressed or focused. The quiet grey is under 4.5:1 on those fills, so the description takes the label's colour there." }
- when: { state: SelectedRow }
elements:
root:
box-shadow: { value: "inset var(--spacing-outline-medium) 0 0 0 var(--table-item-selected-row-edge)", untokenised: "Composed from tokens: a 2px bar down the left of a selected row's first cell. The row's dark green fill is 2:1 against the page, under the 3:1 a selected row needs to be seen (WCAG 1.4.11); the bar is 10:1 in dark and 6:1 in light. A `<tr>` can't draw it, so its first cell does." }
- when: { header: Row }
elements:
label:
font-weight: { token: typography/paragraph/font-weight/medium, value: "500" }
- when: { header: Column }
elements:
root:
padding-top: { token: spacing/gap/2xsmall, value: 4px, notes: "A header row is lower than a row of data." }
padding-bottom: { token: spacing/gap/2xsmall, value: 4px }
vertical-align: { value: bottom, assert: false }
label:
font-weight: { token: typography/label/font-weight/medium, value: "500" }
font-size: { token: typography/label/font-size, value: 12px }
line-height: { token: typography/label/line-height, value: 14px }
letter-spacing: { token: typography/label/letter-spacing, value: 0px }
- when: { sort: None }
elements:
sort-icon:
display: { value: none, assert: false, notes: "Only the sorted column shows an arrow." }
- when: { sort: Ascending }
elements:
sort-icon:
mask-image: { value: "url(./icon-arrow-up.svg)", assert: false, notes: "Icon's arrow-up: smallest first." }
- when: { sort: Descending }
elements:
sort-icon:
mask-image: { value: "url(./icon-arrow-down.svg)", assert: false, notes: "Icon's arrow-down: largest first." }
- when: { state: SortHover }
elements:
sort:
text-decoration: { value: underline, assert: false }
text-underline-offset: { token: spacing/gap/3xsmall, value: 2px }
- when: { state: SortFocus }
elements:
sort:
outline: { value: "var(--spacing-outline-medium) solid var(--table-item-sort-focus-ring)", untokenised: "Composed from tokens: a 2px ring in table-item/sort/focus-ring." }
outline-offset: { token: spacing/gap/3xsmall, value: 2px }
- when: { numeric: true }
elements:
root:
text-align: { value: right, assert: false }
content:
justify-content: { value: flex-end }
text:
align-items: { value: flex-end, assert: false }
label:
white-space: { value: nowrap, assert: false, notes: "An amount stays on one line, its minus sign too. General Sans has no tabular figures, so amounts line up on their right edge, not digit by digit." }
guidance:
status: agreed
use:
- title: Every cell
text: Every cell of a TableRow.
show: header=None, numeric=False, sort=None
- title: Leading and trailing
text: "`leading` for what kind of thing the row is (a Badge), `trailing` for a note on this one value (an estimate Badge)."
show: header=Row, numeric=False, sort=None
- title: Amounts
text: "`numeric` for every amount, and on that column's header."
show: header=None, numeric=True, sort=None
avoid:
- title: Two lines of description
text: Two lines of description. Say less, or give it a column.
show: header=None, numeric=False, sort=None
- title: A link inside a linked row
text: A link or button of its own in a row that's already a link. See **TableRow**.
behaviour: |-
A cell doesn't react. In a row with `href` or `onSelect` the header cell holds the link or button, and the row draws hover, press and focus for it.
accessibility:
element: "`<td>`, or `<th>` with `scope=\"row\"` or `scope=\"col\"` from `header`."
name: "a row's header cell names its row for screen readers, and names its link or button. A Badge in `leading` or `trailing` is read with the cell. An icon there should be `aria-hidden`; if it means something, say it in words too."
keyboard: "nothing of its own. See **TableRow**."
focus: "none of its own. The row draws the ring."
content: "Short. A date, a name, an amount. The description is one line."
Install
npx github:Runceanu/rost add table-item It lands in src/rost/table-item/, with what it needs and its contract. Install has the rest.
When to use
Every cell
Every cell of a TableRow.
Leading and trailing
leadingfor what kind of thing the row is (a Badge),trailingfor a note on this one value (an estimate Badge).Amounts
numericfor every amount, and on that column's header.
When not to use
Two lines of description
Two lines of description. Say less, or give it a column.
A link inside a linked row
A link or button of its own in a row that's already a link. See TableRow.
Behaviour
A cell doesn't react. In a row with href or onSelect the header cell holds the link or button, and the row draws hover, press and focus for it.
Accessibility
- Element
<td>, or<th>withscope="row"orscope="col"fromheader. - Name
a row's header cell names its row for screen readers, and names its link or button. A Badge in
leadingortrailingis read with the cell. An icon there should bearia-hidden; if it means something, say it in words too. - Keyboard
nothing of its own. See TableRow.
- Focus
none of its own. The row draws the ring.
Content
Short. A date, a name, an amount. The description is one line.
Props
| Prop | Type | Values | Default |
|---|---|---|---|
content | slot | | |
description | slot | | |
leading | slot | | |
trailing | slot | | |
header | enum | None · Row · Column | None |
numeric | boolean | | false |
sort | enum | None · Ascending · Descending | None |
States: Default, Highlighted, SelectedRow, SortHover, SortFocus.
Values
Straight from the contract. Each value sits next to its token, because six tokens here all come out as #3a3a3a and the colour alone can't tell you which one is right.
Never changes
root
-
padding-top8pxspacing/gap/small -
padding-bottom8pxspacing/gap/small -
padding-left12pxspacing/gap/small-medium -
padding-right12pxspacing/gap/small-medium
text-alignleft · font-weightinherit
action
displayblock · width100% · padding0 · backgroundnone · bordernone · colorinherit · fontinherit · text-aligninherit · text-decorationnone · cursorpointer · outlinenone
cover
positionabsolute · inset0
sort
-
gap4pxspacing/gap/2xsmall -
border-radius4pxspacing/radius/xsmall
displayinline-flex · align-itemscenter · padding0 · bordernone · backgroundnone · colorinherit · fontinherit · text-aligninherit · cursorpointer · outlinenone
sort-icon
-
width16pxspacing/size/2xsmall -
height16pxspacing/size/2xsmall
displayblock · flex-shrink0 · backgroundcurrentColor · mask-size100% 100% · mask-repeatno-repeat
content
-
gap8pxspacing/gap/small
displayflex · align-itemscenter
leading
displayflex · align-itemscenter · flex-shrink0
text
-
gap2pxspacing/gap/3xsmall
displayflex · flex-directioncolumn · min-width0
label
overflow-wrapanywhere
description
-
font-weight400typography/label/font-weight/regular -
font-size12pxtypography/label/font-size -
line-height14pxtypography/label/line-height -
letter-spacing0pxtypography/label/letter-spacing -
color#999999table-item/sub-label
trailing
displayflex · align-itemscenter · flex-shrink0
Changes by variant
10 variants. Each table is what one thing changes with: a column per header, a row per property. Where every row starts with the same token path, it's written once, under the property.
Follows header
In 2 variants
| Property | Row | Column |
|---|---|---|
label.font-weighttypography/… | paragraph/font-weight/medium 500 | label/font-weight/medium 500 |
Follows sort
In 2 variants
| Property | Ascending | Descending |
|---|---|---|
sort-icon.mask-image | url(./icon-arrow-up.svg) | url(./icon-arrow-down.svg) |
Only in some variants
These don't change: they're just set in some variants and not others.
Numeric
-
content.justify-contentflex-endlayout -
label.white-spacenowraplayout -
root.text-alignrightlayout -
text.align-itemsflex-endlayout
Highlighted
-
description.color#edededtable-item/highlighted/sub-label
Column
-
label.font-size12pxtypography/label/font-size -
label.letter-spacing0pxtypography/label/letter-spacing -
label.line-height14pxtypography/label/line-height -
root.padding-bottom4pxspacing/gap/2xsmall -
root.padding-top4pxspacing/gap/2xsmall -
root.vertical-alignbottomlayout
SelectedRow
-
root.box-shadowinset var(--spacing-outline-medium) 0 0 0 var(--table-item-selected-row-edge)on purpose: Composed from tokens: a 2px bar down the left of a selected row's first cell. The row's dark green fill is 2:1 against the page, under the 3:1 a selected row needs to be seen (WCAG 1.4.11); the bar is 10:1 in dark and 6:1 in light. A `<tr>` can't draw it, so its first cell does.
None
-
sort-icon.displaynonelayout
SortFocus
-
sort.outlinevar(--spacing-outline-medium) solid var(--table-item-sort-focus-ring)on purpose: Composed from tokens: a 2px ring in table-item/sort/focus-ring. -
sort.outline-offset2pxspacing/gap/3xsmall
SortHover
-
sort.text-decorationunderlineFigma frame size -
sort.text-underline-offset2pxspacing/gap/3xsmall
Part of Table
TableRow
One row of a Table, with a hairline under it. It can be a link or something you pick, through its header cell.
Default · Not selectedDefault · SelectedHover, press or tab to one to see the other 6 states.
import { TableRow } from 'rost/components/table-row/TableRow'
// A link: the header cell holds it, and the whole row is the target.
<TableRow href={`/payments/${p.id}`} selected={p.id === current}>
<TableItem header="row" description={p.label}>{p.date}</TableItem>
<TableItem numeric>{eur(p.amount)}</TableItem>
</TableRow>
// Something you pick: the header cell holds a button with aria-pressed.
<TableRow onSelect={() => setPicked(p.id)} selected={p.id === picked}>…</TableRow> src/components/table-row/TableRow.tsx
import { createContext, type HTMLAttributes, type ReactNode } from 'react'
import './table-row.css'
export interface TableRowProps extends Omit<HTMLAttributes<HTMLTableRowElement>, 'onSelect'> {
/** Makes the row a link. The row's header cell holds it. */
readonly href?: string
/** Makes the row something you pick. The row's header cell holds the button. */
readonly onSelect?: () => void
/** The picked row: a dark green fill. */
readonly selected?: boolean
/** The TableItems, one per column. */
readonly children?: ReactNode
}
/** What the row's header cell needs to be its link or button. */
export const RowAction = createContext<Pick<TableRowProps, 'href' | 'onSelect' | 'selected'>>({})
const b = 'rost-table-row'
/**
* One row of a Table. A `<tr>` can't be a link, so with `href` or `onSelect`
* the row's header cell (TableItem `header="row"`) becomes the link or button,
* stretched over the whole row. Hover, press and focus are drawn on the row.
* Built from contracts/table-row.contract.yaml.
*/
export function TableRow({ href, onSelect, selected = false, children, className, ...rest }: TableRowProps) {
return (
<tr className={[b, selected && `${b}--selected`, className].filter(Boolean).join(' ')} {...rest}>
<RowAction.Provider value={{ href, onSelect, selected }}>{children}</RowAction.Provider>
</tr>
)
}
The source for everything on this page: contracts/table-row.contract.yaml (opens in a new tab). The CSS, the docs and the checks in each app are built from it.
# yaml-language-server: $schema=../schema/component-contract.schema.json
schemaVersion: 2
id: table-row
name: TableRow
partOf: table
kind: component
status: review
summary: One row of a Table, with a hairline under it. It can be a link or something you pick, through its header cell.
category: display
related: [ table, table-item, list-item ]
source:
tool: figma
fileKey: 1Zy0wiWKXQAvsfDBX3KR0d
nodeId: "527:483"
url: https://www.figma.com/design/1Zy0wiWKXQAvsfDBX3KR0d/UI-Kit-v01?node-id=527-483
extractedAt: "2026-10-30"
extractedBy: hand
frozenAt: "2026-10-30"
props:
items: { type: slot, notes: "The TableItems, one per column. In React, the children." }
href: { type: string, notes: "Optional. Makes the row a link: the row's header cell (TableItem with `header=\"row\"`) wraps its content in an `<a>` that covers the whole row." }
selected: { type: boolean, default: false, notes: "The picked row, or the current page's in a list of links. A dark green fill; the text keeps its colours. In React, `onSelect` makes a row you pick: the header cell's content becomes a `<button>` that covers the row, with `aria-pressed` from `selected`." }
states: [ Default, Hover, Pressed, Focus ]
stateSelectors:
Hover: ":has(.rost-table-item__action:hover)"
Pressed: ":has(.rost-table-item__action:active)"
Focus: ":has(.rost-table-item__action:focus-visible)"
elements:
root:
notes: "A `<tr>`. Only a row with a link or a button in it reacts to the pointer and to focus: the states come from that `action`, not from the row."
styles:
position: { value: relative, assert: false, notes: "So the action's cover can stretch over the whole row." }
height: { token: spacing/size/medium-large, value: 48px, notes: "The least a row is, as ListItem. A row with a description grows." }
border-sides: { value: bottom }
border-width: { token: spacing/outline/small, value: 1px }
border-color: { token: table-row/divider, value: "#282828", notes: "The hairline between rows, the one the accounting app's rows had." }
variants:
- when: { state: Default, selected: true }
figmaNode: "527:217"
elements:
root:
background: { token: table-row/selected/default/background, value: "#004c19", notes: "Quieter than ListItem's green plate: a table's text stays readable in its own colours." }
- when: { state: Hover, selected: false }
figmaNode: "527:255"
elements:
root:
background: { token: table-row/unselected/hover/background, value: "#171717" }
- when: { state: Hover, selected: true }
figmaNode: "527:293"
elements:
root:
background: { token: table-row/selected/hover/background, value: "#006f27" }
- when: { state: Pressed, selected: false }
figmaNode: "527:331"
elements:
root:
background: { token: table-row/unselected/pressed/background, value: "#3a3a3a" }
- when: { state: Focus }
elements:
root:
outline-style: { value: solid, assert: false }
outline-width: { token: spacing/outline/medium, value: 2px }
outline-offset: { value: -2px, untokenised: "Inside the row, the ring's own width, so it isn't cut by the rows around it." }
outline-color: { token: table-row/focus/focus-ring, value: "#999999" }
guidance:
status: agreed
use:
- title: Every row
text: Every row of a Table, the header row too.
show: state=Default, selected=False
- title: A row that opens something
text: "A row that opens the thing it shows, with `href`: a payment, an invoice, a client."
show: state=Hover, selected=False
avoid:
- title: Controls in a linked row
text: "Links or buttons in several cells of a row that's itself a link. The cover sits over them. Pick one: the row, or the controls."
show: state=Default, selected=False
- title: A status as a fill
text: Showing a status with the fill. `selected` means picked; a status is a **Badge** in a cell.
behaviour: |-
A row with `href` or `onSelect` is one target: the pointer anywhere on it hovers and presses it, and focus draws a ring round the whole row. A plain row doesn't react. `selected` keeps its fill on hover, a shade lighter.
accessibility:
element: "a `<tr>`. The link or button lives in the row's header cell, because a `<tr>` can't be one. Its cover stretches over the row, so the whole row is the target."
name: "the header cell's content: the link or button is named by what's in it, a date or a client's name. Make that cell say which row it is."
keyboard: "a linked row is one Tab stop. Enter follows the link; Enter or Space presses the button."
focus: "a 2px ring inside the row, on `:focus-visible` of its link or button."
content: "One thing per row. The header cell names it."
Install
npx github:Runceanu/rost add table-row It lands in src/rost/table-row/, with what it needs and its contract. Install has the rest.
When to use
Every row
Every row of a Table, the header row too.
A row that opens something
A row that opens the thing it shows, with
href: a payment, an invoice, a client.
When not to use
Controls in a linked row
Links or buttons in several cells of a row that's itself a link. The cover sits over them. Pick one: the row, or the controls.
A status as a fill
Showing a status with the fill.
selectedmeans picked; a status is a Badge in a cell.
Behaviour
A row with href or onSelect is one target: the pointer anywhere on it hovers and presses it, and focus draws a ring round the whole row. A plain row doesn't react. selected keeps its fill on hover, a shade lighter.
Accessibility
- Element
a
<tr>. The link or button lives in the row's header cell, because a<tr>can't be one. Its cover stretches over the row, so the whole row is the target. - Name
the header cell's content: the link or button is named by what's in it, a date or a client's name. Make that cell say which row it is.
- Keyboard
a linked row is one Tab stop. Enter follows the link; Enter or Space presses the button.
- Focus
a 2px ring inside the row, on
:focus-visibleof its link or button.
Content
One thing per row. The header cell names it.
Props
| Prop | Type | Values | Default |
|---|---|---|---|
items | slot | | |
href | string | | |
selected | boolean | | false |
States: Default, Hover, Pressed, Focus.
Values
Straight from the contract. Each value sits next to its token, because six tokens here all come out as #3a3a3a and the colour alone can't tell you which one is right.
Never changes
root
-
height48pxspacing/size/medium-large -
border-width1pxspacing/outline/small -
border-color#282828table-row/divider
positionrelative · border-sidesbottom
Changes by variant
5 variants. Each table is what one thing changes with: a column per state, a row per property. Where every row starts with the same token path, it's written once, under the property.
Follows state and selected
Selected
| Property | Default | Hover | Pressed |
|---|---|---|---|
root.backgroundtable-row/selected/… | default/background #004c19 | hover/background #006f27 | · |
Not selected
| Property | Default | Hover | Pressed |
|---|---|---|---|
root.backgroundtable-row/unselected/… | · | hover/background #171717 | pressed/background #3a3a3a |
Only in some variants
These don't change: they're just set in some variants and not others.
Focus
-
root.outline-color#999999table-row/focus/focus-ring -
root.outline-offset-2pxon purpose: Inside the row, the ring's own width, so it isn't cut by the rows around it. -
root.outline-stylesolidFigma frame size -
root.outline-width2pxspacing/outline/medium