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

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

## Install

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

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

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 |
|---|---|---|---|
| `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`

## Anatomy

- `root`: 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.
- `action` (optional): 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.
- `cover` (optional): An empty layer inside the action, stretched over the whole row, so the pointer anywhere on the row hovers and presses the link.
- `sort` (optional): 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.
- `sort-icon` (optional): Icon's arrow-up or arrow-down at 16px, as a mask in the header's colour.
- `content`: Leading, the text and trailing, side by side.
- `leading` (optional)
- `text`: The content over the description.
- `label`: In the text colour, inherited from the Table.
- `description` (optional)
- `trailing` (optional)

## When to use

- **Every cell.** Every cell of a TableRow.
- **Leading and trailing.** `leading` for what kind of thing the row is (a Badge), `trailing` for a note on this one value (an estimate Badge).
- **Amounts.** `numeric` for 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>` 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.

## Tokens

Every token this component uses, across all its variants.

| Token | Resolves to |
|---|---|
| `spacing/gap/2xsmall` | `4px` |
| `spacing/gap/3xsmall` | `2px` |
| `spacing/gap/small` | `8px` |
| `spacing/gap/small-medium` | `12px` |
| `spacing/radius/xsmall` | `4px` |
| `spacing/size/2xsmall` | `16px` |
| `table-item/highlighted/sub-label` | `#ededed` |
| `table-item/sub-label` | `#999999` |
| `typography/label/font-size` | `12px` |
| `typography/label/font-weight/medium` | `500` |
| `typography/label/font-weight/regular` | `400` |
| `typography/label/letter-spacing` | `0px` |
| `typography/label/line-height` | `14px` |
| `typography/paragraph/font-weight/medium` | `500` |

## No token, on purpose

| Part | Property | Value | Why |
|---|---|---|---|
| `action` | `width` | `100%` | As wide as its cell. |
| `root` | `box-shadow` | `inset var(--spacing-outline-medium) 0 0 0 var(--table-item-selected-row-edge)` | 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. |
| `sort` | `outline` | `var(--spacing-outline-medium) solid var(--table-item-sort-focus-ring)` | Composed from tokens: a 2px ring in table-item/sort/focus-ring. |

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