Elastic slider
A slider that stretches like rubber past its ends, with a swaying value tag and detents the thumb clicks into.
Pick a value or a range on a track that follows your finger.
npx shadcn@latest add @silicon-ui/slidernpx shadcn@latest add @silicon-ui/sliderInstall the dependencies.
npm install motionCopy these files into your project. Shared files are skipped if you already have them.
components/silicon-ui/slider/slider.tsxcomponents/silicon-ui/slider/slider.module.cssInstall the foundation once per app for the design and motion tokens: npx shadcn@latest add @silicon-ui/silicon-foundation
| 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 | — |