Slider
Picks a value, or a range with two thumbs, along a track. Keyboard steps with the arrows, large steps with Page Up and Down.
Installation
Or with the shadcn CLI, from the registry:
Usage
Range
Pass an array to get one thumb per value. minStepsBetweenValues keeps the thumbs apart.
Tones
tone colours the range and the thumb's ring: primary by default. The ring takes the tone's edge, 3:1 on the page even for warning.
Sizes
sm, default and lg set the track's thickness and the thumb, at the village's indicator sizes.
Villages
The track and range follow --track-border and the nature's primary; the thumb has no shadow in Iwa.
Accessibility
- Each thumb is a
sliderwitharia-valuenow;aria-labelon the Slider names every thumb. - Arrow keys move by
step, Page Up and Page Down bylargeStep, Home and End to the ends.
API reference
The props of Base UI's Slider root (value, defaultValue, onValueChange, onValueCommitted, min, max, step, largeStep, minStepsBetweenValues, orientation, disabled…), plus tone ("neutral" \| "primary" \| "success" \| "warning" \| "info" \| "destructive", default "primary"), size ("sm" \| "default" \| "lg") and className. Its track, range and thumbs are drawn for you; sliderVariants({ tone, size }) returns the root's classes.