Elastic Slider
ProNewPhysics-driven slider that stretches elastically past its min and max bounds and snaps back on release.
Installation
pnpm dlx shadcn@latest add @viewport/elastic-slider
First time? Add the @viewport registry to components.json. Setup takes one minute.
Usage
The code behind the preview above comes with Truffle Pro.
Props
| Prop | Type | Default |
|---|---|---|
| defaultValue | numberInitial value between `min` and `max`. | 64 |
| min | number | 0 |
| max | number | 100 |
| step | number | 1 |
| label | stringAccessible label for the slider. | "Output volume" |
| unit | stringUnit suffix shown in the readout, e.g. "%". | "%" |
| onValueChange | (value: number) => voidCalled whenever the value changes. | — |
| className | string | — |
Accessibility
- Exposed as role=slider with min, max, now, and formatted aria-valuetext.
- Supports Arrow keys, Shift+Arrow for larger jumps, Home, and End.
- Elastic overscroll stretching is disabled under reduced motion.