# Slider

> A number picked by dragging, when about right is right: a 4px track, a green fill and a 20px thumb. The arrow keys move it a step at a time.

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

## Install

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

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

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 |
|---|---|---|---|
| `value` | number |  |  |
| `min` | number |  | `0` |
| `max` | number |  | `100` |
| `step` | number |  | `1` |
| `label` | string |  |  |
| `valueText` | string |  |  |
| `disabled` | boolean |  | `false` |

## States

`Default` · `Focus` · `Disabled`

## Anatomy

- `root`: The area you press and drag in: as wide as its parent, 24px tall, so the thumb has room and a press near the track still counts.
- `track`: Progress's 4px grey track, centred in the 24px.
- `fill`: From the start to the middle of the thumb, in the primary green. Its width is set from `value`.
- `thumb`: A 20px dot in the main text colour, centred on the track. It's the part that has the focus and the `role="slider"`.
- `focus-ring`: Checkbox's ring, 4px out from the thumb, round like it.

## When to use

- **Roughly how much.** A share to set aside, a zoom level, how many months to show: where nudging until it looks right beats typing.

## When not to use

- **An exact amount.** A figure someone already knows, like an invoice total. That's an **Input**.
- **A handful of options.** Three or four named choices aren't a range. That's a **ToggleGroup** or **Radios**.

## Behaviour

Press anywhere along it and the thumb jumps there; drag to move it. The arrow keys move one step, Page Up and Page Down ten, Home and End to the ends. It calls `onValueChange` with the new number; show that number next to it.

## Accessibility

- **Element**: The thumb is `role="slider"` with `aria-valuenow`, `aria-valuemin`, `aria-valuemax` and `aria-valuetext` when it's given. The track and fill are drawing.
- **Name**: `label`, as `aria-label` on the thumb, or point `aria-labelledby` at a visible label.
- **Colour**: The thumb is 17:1 on the dark page and the fill 10:1. The track is 1.8:1, a quiet edge: the fill and thumb carry the value, not the track.

## Content

Write the value beside it, in its units. The label says what it sets: Share set aside for tax.

## Tokens

Every token this component uses, across all its variants.

| Token | Resolves to |
|---|---|
| `opacity/gentle` | `0.24` |
| `slider/fill` | `#00d669` |
| `slider/focus-ring` | `#999999` |
| `slider/thumb` | `#ededed` |
| `slider/track` | `#3a3a3a` |
| `spacing/gap/2xsmall` | `4px` |
| `spacing/gap/3xsmall` | `2px` |
| `spacing/outline/medium` | `2px` |
| `spacing/radius/full` | `10000px` |
| `spacing/size/small` | `24px` |
| `spacing/size/xsmall` | `20px` |

## No token, on purpose

| Part | Property | Value | Why |
|---|---|---|---|
| `track` | `top` | `calc(50% - var(--spacing-gap-2xsmall) / 2)` | Composed from a token: the middle of the root, less half the track. |
| `fill` | `top` | `calc(50% - var(--spacing-gap-2xsmall) / 2)` | Composed from a token: on the track. |
| `focus-ring` | `inset` | `calc(-1 * var(--spacing-gap-2xsmall))` | Composed from a token: the ring sits spacing/gap/2xsmall outside the thumb. |

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