# 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.

| | |
|---|---|
| Kind | component |
| Contract | `review` · [table.contract.yaml](https://github.com/Runceanu/rost/blob/master/contracts/table.contract.yaml) |
| Guidance | `agreed` |
| Source | [Figma 527:596](https://www.figma.com/design/1Zy0wiWKXQAvsfDBX3KR0d/UI-Kit-v01?node-id=527-596) · read 2026-10-30 · frozen 2026-10-30 |
| Implemented in | nowhere yet |

## Install

It lands in `src/rost/table/`, with what it needs and its contract:

```sh
npx github:Runceanu/rost add table
```

Then import `src/rost/fonts.css` and `src/rost/tokens.css` once, at the root of the app. More on this in [Install](https://rost.build/docs/install.md).

## Props

| Prop | Type | Values | Default |
|---|---|---|---|
| `caption` | slot |  |  |
| `head` | slot |  |  |
| `rows` | slot |  |  |

## Anatomy

- `root`: A real `<table>`. It has no surface of its own: no box, no fill. The rows draw the lines.
- `caption` (optional): The `<caption>`, above the rows, lined up with the text in the first column.
- `head` (optional): The `<thead>`. Only there when `head` is.
- `body`: The `<tbody>` with the rows.

## 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 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.

## Tokens

Every token this component uses, across all its variants.

| Token | Resolves to |
|---|---|
| `font-family/base` | `'General Sans Variable'` |
| `non-interactive/foreground/primary` | `#ededed` |
| `spacing/gap/small` | `8px` |
| `spacing/gap/small-medium` | `12px` |
| `typography/paragraph/font-size` | `14px` |
| `typography/paragraph/font-weight/medium` | `500` |
| `typography/paragraph/font-weight/regular` | `400` |
| `typography/paragraph/letter-spacing` | `0px` |
| `typography/paragraph/line-height` | `20px` |

## No token, on purpose

| Part | Property | Value | Why |
|---|---|---|---|
| `root` | `width` | `100%` | As wide as where it sits. |

See it live, with every value of every variant: [rost.build/components/table/](https://rost.build/components/table/)
