Components
Slider
Bounded numeric control. Prefer for imprecise ranges; if the value needs to be entered exactly, use an Input with type=number.
When to usefor imprecise numeric input where the operator wants to feel the value move — thresholds, filters, opacity, zoom.
Import
import { Slider } from "@ravnhq/efni/slider"Single value
value: 42
const [value, setValue] = useState<number[]>([42]);
<Slider value={value} onValueChange={setValue} />Range (two thumbs)
range: 25 – 75
const [range, setRange] = useState<number[]>([25, 75]);
<Slider value={range} onValueChange={setRange} min={0} max={100} />Disabled
Accessibility
| Key | Action |
|---|---|
| ← / → | Adjust the value by step (default 1). |
| PgDn / PgUp | Larger step (10× step). |
| Home / End | Jump to min / max. |
| Tab | Move focus between thumbs (range mode). |
- Value is always an array — [n] for single, [n, m] for range — even in uncontrolled mode.
- Pair with a live text readout so the value is announced by screen readers as it changes.
Guidelines
Do
- Show the current value near the slider — a bare track is hard to read.
- Set min, max, step to match the real domain (percent, hours, kg).
- Use range mode for from/to filters where operators care about span.
Don't
- Don't use for precise numbers (IDs, prices) — use Input type=number.
- Don't leave the value invisible during drag — the thumb tooltip or an adjacent label is required.
- Don't nest sliders inside dense table cells — the target is too small.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
value | Value | — | The value of the slider. For range sliders, provide an array with one value per thumb. |
defaultValue | Value | — | The uncontrolled value of the slider when it's initially rendered. To render a controlled slider, use the value prop instead. |
onValueChange | ((value: Value extends number ? number : Value, eventDetails: SliderRoot.ChangeEventDetails) => void) | — | Callback function that is fired when the slider's value changed. |
min | number | 0 | The minimum allowed value of the slider. Should not be equal to max. |
max | number | 100 | The maximum allowed value of the slider. Should not be equal to min. |
step | number | 1 | The granularity with which the slider can step through values. |
disabled | boolean | false | Whether the slider should ignore user interaction. |
…props | SliderPrimitive.Root.Props | — | Everything Slider passes to the element it renders. |