Elastic Slider
betaA slider made of rubber: pull past either end and the track stretches after you, pushing the icon aside, then springs back.
- Forms
- 1 file
- 3 npm packages
- Accessibility notes
- Animates with motion
Loading the example…
pnpm dlx @dowel-ui/cli add elastic-slidernpm packages installed: class-variance-authority, motion, radix-ui.
import { ElasticSlider } from "@/components/ui/elastic-slider";Default
Controlled
Small
<ElasticSlider>
| Prop | Type | Default |
|---|---|---|
defaultValue | number | 50 |
endIconShown at the inline end; nudged outwards when the track is pulled past it. | ReactNode | — |
formatValueFormats the floating value and the spoken | (value: number) => string | String |
maxStretchThe furthest the track stretches past an end, in px. | number | 16 |
onValueChange | (value: number) => void | — |
onValueCommit | (value: number) => void | — |
showValueFloat the value above the thumb while it is held. Default true. | boolean | true |
size | "sm" | "md" | "md" |
startIconShown at the inline start; nudged outwards when the track is pulled past it. | ReactNode | — |
value | number | — |
Every prop of Radix UI’s Slider.Root, plus className.
Built on the Radix slider: a role="slider" thumb with arrow keys, Home/End, Page Up/Down, right-to-left and a hidden form input. Name it with aria-label or aria-labelledby; formatValue sets the spoken aria-valuetext as well as the floating label. The floating value also shows on keyboard focus. The stretch is decoration on top of an ordinary slider and never happens under reduced motion; the icons are aria-hidden.
10/10
checks passed
- Tested — passes
- axe assertion — passes
- Keyboard tested — passes
- Storybook examples — passes
- Accessibility documented — passes
- Semantic tokens only — passes
- Motion from tokens — passes
- className merged — passes
- Visible focus — passes
- No fixed widths — passes