Skip to Content
zjkm-ui
Components

Range Slider

A slider with a filled track.

50%
Props
<RangeSlider label="Volume" />

Installation

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

PropTypeDefaultDescription
labelstringThe label.
defaultValuenumberthe middleStarting value.
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) => voidCalled as the value changes.
colorstring"#6366f1"Fill and thumb colour.
classNamestringClasses for the wrapper.

It has no animation, so reduced motion changes nothing.

On this page