# Sparkline

> Which way something has been going, as a small line with a dot at now. Green when that's good, red when it isn't, grey when it's neither.

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

## Install

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

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

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 |
|---|---|---|---|
| `data` | node |  |  |
| `tone` | enum | `neutral` `positive` `negative` | `neutral` |
| `label` | string |  |  |
| `width` | number |  | `120` |

## Anatomy

- `root`: A `<span role="img">` named by `label`, holding the SVG.
- `svg`: The drawing: as wide as `width`, 32px tall, with 3px kept clear on every side so the dot isn't cut.
- `line`: The values joined, lowest at the bottom and highest at the top, a 2px line with round ends and joins.
- `dot`: The last value, a 6px dot in the line's colour: now.

## When to use

- **Next to a figure.** Beside a Stat, to say whether this month's number is part of a rise or a dip.

## When not to use

- **Reading values off it.** It has no axis on purpose. When the amounts matter, that's a **BarChart** or a **Table**.
- **Tone as the only signal.** The Stat next to it says up or down in words. Red alone doesn't.

## Behaviour

It scales the values to fit: the lowest touches the bottom, the highest the top, so it shows shape, not size. A flat series sits in the middle.

## Accessibility

- **Element**: `<span role="img">`; the SVG inside is hidden from screen readers.
- **Name**: `label`, which has to say what the line shows, since nobody can hear its shape.
- **Colour**: A graphic that carries meaning: the grey is 7:1, the green 10:1, the red 7:1 on the dark page.

## Content

The label ends with where it ended up: up to €12,000, not just Income.

## Tokens

Every token this component uses, across all its variants.

| Token | Resolves to |
|---|---|
| `spacing/outline/medium` | `2px` |
| `spacing/size/small-medium` | `32px` |
| `sparkline/negative` | `#f2705f` |
| `sparkline/neutral` | `#999999` |
| `sparkline/positive` | `#00d669` |

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