Components
An input where the user selects a value from within a given range.
Playground
defaultValue as an array — the component renders one thumb per entry. Set the range with min, max and step; the track fills with primary up to the thumb.import { Slider } from "@workspace/ui/components/slider"
<Slider defaultValue={[33]} max={100} step={1} />step. Use minStepsBetweenThumbs to prevent the thumbs from overlapping.<Slider defaultValue={[25, 50]} max={100} step={5} />onValueChange receives the full sorted array. Useful for multi-stop controls like gradient or breakpoint editors.<Slider defaultValue={[10, 20, 70]} max={100} step={10} />value and onValueChange to control the state — the callback fires on every move while dragging. Listen to onValueCommit instead when you only care about the final value, such as persisting a setting.const [volume, setVolume] = React.useState([40])
<Label>Volume: {volume[0]}</Label>
<Slider value={volume} onValueChange={setVolume} max={100} step={1} />orientation="vertical" to rotate the slider — the track grows to fill the container height, with a 160px minimum. Values increase from bottom to top; pass inverted to flip the direction.<div className="flex h-48 justify-center gap-12">
<Slider defaultValue={[30]} max={100} step={1} orientation="vertical" />
<Slider defaultValue={[20, 80]} max={100} step={1} orientation="vertical" />
</div>disabled prop to prevent interaction — the whole control dims to 50% opacity via data-disabled and stops receiving pointer and keyboard events. The current value stays visible.<Slider defaultValue={[50]} max={100} step={1} disabled />dir="rtl" on the slider or inherit it from a Direction provider — the track fills from the right and arrow keys follow the reading direction.<div dir="rtl" className="space-y-3">
<Label>مستوى الصوت</Label>
<Slider defaultValue={[33]} max={100} step={1} dir="rtl" />
</div>defaultValue or controlled via value + onValueChange. Every value is an array with one entry per thumb. Inside a form, each thumb submits its value under name.| Prop | Type | Default |
|---|---|---|
| defaultValue | number[] | — |
| value | number[] | — |
| onValueChange | (value: number[]) => void | — |
| onValueCommit | (value: number[]) => void | — |
| min | number | 0 |
| max | number | 100 |
| step | number | 1 |
| minStepsBetweenThumbs | number | 0 |
| orientation | "horizontal" | "vertical" | "horizontal" |
| dir | "ltr" | "rtl" | — |
| inverted | boolean | false |
| disabled | boolean | — |
| name | string | — |
| form | string | — |
Tokens used
5 design tokens consumed by the Slider component.
--primary
Primary
--muted
Muted
--background
Background
--ring
Ring
--spacing
Spacing unit (4px)