Slider
Pick a value or a range on a track that follows your finger.
npx shadcn@latest add @silicon-ui/sliderInstallation
With the shadcn CLI
npx shadcn@latest add @silicon-ui/sliderManually
Install the dependencies
npm install motionCopy these files into your project
- components/silicon-ui/slider/slider.tsx
- components/silicon-ui/slider/slider.module.css
Add the foundation, once per app, for the design and motion tokens
npx shadcn@latest add @silicon-ui/silicon-foundation
Usage
API reference
| Prop | Type | Default |
|---|---|---|
label*Visible label. Range thumbs are named from it unless `thumbLabels` says otherwise. | string | — |
valueA number for one thumb, a pair for a range. | T | — |
defaultValue | T | — |
onValueChange | (value: T) => void | — |
onValueCommitRuns once a drag is released or a key changes the value, for work too heavy for every step. | (value: T) => void | — |
min | number | 0 |
max | number | 100 |
step | number | 1 |
largeStepPageUp, PageDown, and Shift with an arrow move this far. Defaults to a tenth of the range. | number | — |
marksTicks on the track. A number draws a tick; a mark with a label also prints it under the track, and clicking it moves there. | (number | SliderMark)[] | — |
minStepsBetweenThumbsThe closest two range thumbs may sit, in steps. | number | 0 |
formatFormats the readout, the bubble, and the spoken value. | (value: number) => string | — |
showValueShow the value beside the label. The bubble over the thumb still appears while dragging or focused. | boolean | true |
thumbLabelsAccessible names for the two range thumbs. | [string, string] | — |
startContent beside the track, such as an icon or a mute button. | ReactNode | — |
end | ReactNode | — |
nameSubmits the value with a form, one hidden input per thumb. | string | — |
disabled | boolean | — |
className | string | — |
Dependencies
- npm
- motion
- Registry
- silicon-motion-tokens