Slider
Pick a value or a range on a track that follows your finger.
A slider that stretches like rubber past its ends, with a swaying value tag and detents the thumb clicks into.
npx shadcn@latest add @silicon-ui/elastic-slidernpx shadcn@latest add @silicon-ui/elastic-sliderInstall the dependencies.
npm install motionCopy these files into your project. Shared files are skipped if you already have them.
components/silicon-ui/elastic-slider/elastic-slider.tsxcomponents/silicon-ui/elastic-slider/elastic-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; it also names the thumb. | string | — |
value | number | — |
defaultValue | number | — |
onValueChange | (value: number) => void | — |
onValueCommitRuns once a drag is released or a key changes the value. | (value: number) => 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 | — |
marksDetents. A dragged thumb clicks into each one and holds for a few pixels before letting go. Labels print under the track. | (number | ElasticSliderMark)[] | — |
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 using keys. | boolean | true |
startIconIcons at either end. The one on the side being pulled past its limit is pushed outward with the track. | ReactNode | — |
endIcon | ReactNode | — |
nameSubmits the value with a form. | string | — |
disabled | boolean | — |
className | string | — |