Forms

Slider

A value, or a range with two thumbs, along a track. Base UI Slider; values are arrays.

packages/design-system/components/ui/slider.tsx

Examples

One value
A range
Stepped, 0 to 10
Disabled

Anatomy

  1. 01Track, 8px
  2. 02Range indicator, primary
  3. 03Thumb, 24 by 16, white

Usage

import { Slider } from "@repo/design-system/components/ui/slider";

<Slider value={[size]} onValueChange={(value) => setSize(value as number)} min={12} max={96} step={1} />

Props

PropTypeDefaultDescription
value / defaultValuenumber | number[]noneOne number per thumb. With neither, it renders two thumbs at min and max.
onValueChange(value, details) => voidnoneCalled while dragging.
minnumber0Lowest value.
maxnumber100Highest value.
stepnumber1Increment.
orientation"horizontal" | "vertical""horizontal"Vertical needs a height on the parent.
classNamestringnoneMerged last with cn(). Use it for layout (width, margin), not to restyle the component.

Guidance

Do

  • Show the current value next to it when the number matters.

Don't

  • Use it for exact numbers. Use an input.