Components
Range Slider
A slider with a filled track.
<RangeSlider label="Volume" />Installation
npx shadcn@latest add https://ui.zjkm.tech/r/range-slider.jsonimport { RangeSlider } from "@/components/range-slider"Using JavaScript? Set tsx: false in components.json and the CLI converts it.
New to shadcn? Run npx shadcn@latest init first. The CLI needs components.json and the @/ import alias.
Usage
A native slider with the track filled up to the thumb and the value shown beside the label. Keyboard, touch and screen readers work as they do on any <input type="range">.
import { RangeSlider } from "@/components/range-slider";
export function Volume() {
return <RangeSlider label="Volume" defaultValue={40} format={(v) => `${v}%`} />;
}Props
| Prop | Type | Default | Description |
|---|---|---|---|
label | string | The label. | |
defaultValue | number | the middle | Starting value. |
min | number | 0 | Lowest value. |
max | number | 100 | Highest value. |
step | number | 1 | Step between values. |
format | (value: number) => string | String | Turns the value into the text shown and read out, e.g. v => `${v}%`. |
onChange | (value: number) => void | Called as the value changes. | |
color | string | "#6366f1" | Fill and thumb colour. |
className | string | Classes for the wrapper. |
It has no animation, so reduced motion changes nothing.