Elastic slider
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-sliderInstallation
With the shadcn CLI
npx shadcn@latest add @silicon-ui/elastic-sliderManually
Install the dependencies
npm install motionCopy these files into your project
- components/silicon-ui/elastic-slider/elastic-slider.tsx
- components/silicon-ui/elastic-slider/elastic-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; 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 | — |
Dependencies
- npm
- motion
- Registry
- silicon-motion-tokens