Skip to Content
zjkm-ui
Components

Stepped Slider

A slider that snaps to labelled steps.

Props
<SteppedSlider label="Team size" steps={["1", "2–5", "6–20", "21–50", "50+"]} />

Installation

npx shadcn@latest add https://ui.zjkm.tech/r/stepped-slider.json
import { SteppedSlider } from "@/components/stepped-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 slider that snaps between labelled steps shown under the track. Screen readers hear the step's label, such as "2–5", not its position.

import { SteppedSlider } from "@/components/stepped-slider";

export function TeamSize() {
  return <SteppedSlider label="Team size" steps={["1", "2–5", "6–20", "21–50", "50+"]} />;
}

Props

PropTypeDefaultDescription
labelstringThe label.
stepsstring[]The step labels, left to right.
defaultIndexnumber0Starting step.
onChange(index: number, step: string) => voidCalled when the step changes.
colorstring"#6366f1"Fill and thumb colour.
classNamestringClasses for the wrapper.

It has no animation, so reduced motion changes nothing.

On this page