Components
Dual Range Slider
A slider with two thumbs for a minimum and maximum.
Price
<DualRangeSlider label="Price" />Installation
npx shadcn@latest add https://ui.zjkm.tech/r/dual-range-slider.jsonimport { DualRangeSlider } from "@/components/dual-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
Two thumbs on one track, for a minimum and a maximum. Each thumb is its own native slider with its own name, so both work from the keyboard, and they can't cross.
import { DualRangeSlider } from "@/components/dual-range-slider";
export function PriceFilter() {
return <DualRangeSlider label="Price" max={500} defaultValue={[80, 320]} format={(v) => `$${v}`} />;
}Props
| Prop | Type | Default | Description |
|---|---|---|---|
label | string | Names the pair. | |
defaultValue | [number, number] | [25, 75] | Starting minimum and maximum. |
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, number]) => void | Called as either thumb moves. | |
color | string | "#6366f1" | Fill and thumb colour. |
className | string | Classes for the wrapper. |
It has no animation, so reduced motion changes nothing.