# Legend

> What a chart's colours mean: a small square of each, its name and, if it helps, its value, in a row that wraps.

| | |
|---|---|
| Kind | component |
| Contract | `review` · [legend.contract.yaml](https://github.com/Runceanu/rost/blob/master/contracts/legend.contract.yaml) |
| Guidance | `proposed` |
| Source | [Figma 753:25](https://www.figma.com/design/1Zy0wiWKXQAvsfDBX3KR0d/UI-Kit-v01?node-id=753-25) · read 2026-11-17 · frozen 2026-11-17 |
| Implemented in | nowhere yet |

## Install

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

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

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

## Anatomy

- `root`: A `<ul>`: the items in a row, 16px apart, wrapping when there's no room.
- `item`: An `<li>`: the square, the name and the value, 6px apart.
- `swatch`: An 8px square with 2px corners, in BarChart's grey.
- `current-swatch`: The same square in BarChart's green.
- `label`: Label type, in the secondary text colour.
- `value` (optional): Label type, medium weight, the main text colour.

## When to use

- **Under a chart.** Under a BarChart, saying that green is this month and grey the ones before, with this month's total.

## When not to use

- **One colour.** A chart with one colour needs a title, not a legend.

## Behaviour

It lists what each colour means, in the order the chart uses them. It doesn't draw the chart or know about it.

## Accessibility

- **Element**: `<ul>`; the squares are drawing, hidden from screen readers, so each item reads as its name and value.
- **Colour**: The names are 11:1 and the values 17:1 on the dark page. The squares are 4.3:1 and 10:1.

## Content

Name what the colour stands for (This month, Earlier), not the colour.

## Tokens

Every token this component uses, across all its variants.

| Token | Resolves to |
|---|---|
| `font-family/base` | `'General Sans Variable'` |
| `legend/current-swatch` | `#00d669` |
| `legend/label` | `#d3d9d5` |
| `legend/swatch` | `#747573` |
| `legend/value` | `#ededed` |
| `spacing/gap/medium` | `16px` |
| `spacing/gap/none` | `0px` |
| `spacing/gap/small` | `8px` |
| `spacing/gap/xsmall` | `6px` |
| `spacing/radius/2xsmall` | `2px` |
| `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` |

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