Slider
Pick a value, or a span of values, where the approximate position matters more than the number.
{/* Generated by scripts/build-component-docs.mjs — do not edit. The source is the component folder: guidance.json, the doc block and the props. Change those. */}
Pick a value, or a span of values, where the approximate position matters more than the number.
Import
import { Slider } from "@ir/ui";Watch out
- The track is a correction. It was drawn on bg/neutral/subtle-pressed, which in dark is neutral-800 — the card itself — so the track vanished on any card, and a resting track should not borrow a state word. It takes bg/layer/emphasis, the system's token for a neutral fill that must be seen on any surface; Progress and Meter use the same. Figma corrected.
- Disabled is a correction. All three Types draw
State=Disabledpixel-identical toState=Default— same fills, same strokes, same effects. A disabled control that looks live is the same defect as the seven Tab focus variants that showed no focus, so the code gives it the system's usual treatment (bg/disabled range, a muted thumb edge) and Figma is owed the fix. - Hover and Focus carry raw drop and inner shadows rather than binding
ring/focus, so the ring here is the system's standard one rather than a reproduction of three unbound effects. Raised.
Props
| Prop | Type | Required | What it does |
|---|---|---|---|
thumbLabels | string[] | Names each thumb for screen readers — one per value. |
Do and don't
Put the number beside it, or let a field mirror it.
Don't — Ship a slider with no readout of the value it is setting.
A thumb on a track is an approximation. Anyone who needs the exact figure — and in a threshold they always do — cannot get it from the position.
Use a slider for ranges people judge by feel; use a number input for exact values.
Don't — Use a slider to enter a port number or a timeout in milliseconds.
Hitting one value in a thousand by dragging is a pointer-accuracy test, and it is much worse on a touchscreen.
Name them — Minimum and Maximum.
Don't — Leave a range slider's two thumbs unlabelled.
A screen reader announces two controls both called "slider", with no way to tell which end is which.
Set a step that matches the precision the value actually has.
Don't — Leave step at 1 on a 0–10000 range.
Ten thousand keyboard presses to cross the track is not keyboard support.
Let the disabled treatment show.
Don't — Leave a disabled slider looking exactly like a live one.
The file draws them identically today. People drag a control that cannot move and conclude the page is broken.
Accessibility
- Radix supplies role="slider", the aria-value* attributes and arrow, Page and Home/End keys on every thumb.
- A range slider has two thumbs and therefore needs two names: pass thumbLabels, or both announce the same thing.
- Disabled removes the hover and focus effects as well as the pointer. A disabled control that still looks live is the same defect as one that looks disabled and is not.
Where it is drawn
Figma — structure from figma, measurements from figma.