Skip to Content
zjkm-ui
Components

Dual Range Slider

A slider with two thumbs for a minimum and maximum.

Price
Props
<DualRangeSlider label="Price" />

Installation

npx shadcn@latest add https://ui.zjkm.tech/r/dual-range-slider.json
import { 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

PropTypeDefaultDescription
labelstringNames the pair.
defaultValue[number, number][25, 75]Starting minimum and maximum.
minnumber0Lowest value.
maxnumber100Highest value.
stepnumber1Step between values.
format(value: number) => stringStringTurns the value into the text shown and read out, e.g. v => `${v}%`.
onChange(value: [number, number]) => voidCalled as either thumb moves.
colorstring"#6366f1"Fill and thumb colour.
classNamestringClasses for the wrapper.

It has no animation, so reduced motion changes nothing.

On this page