Installation
Theme
Mode

Forms & input

Slider

Pick a value — or a span of values — by direct manipulation. Drag the thumb, click anywhere on the track to jump, or nudge with the arrow keys. A live fill and a value bubble keep the current setting legible.

$npx shadcn@latest add @orbit/slider

Playground

Amount
50%
50%
VariantStepUnit

Anatomy

A 6px neutral track holds the full min→max range; a brand-colored fill shows how far the value has travelled; an 18px thumb marks the exact point and surfaces a value bubble while it moves.

Track · fill · thumb + bubble — drag to see each part
Brightness
58%
58%

Variants

One value, a span between two thumbs, or a snap-to-notch stepped scale with a labelled axis. Set with the variant prop.

single — one thumb · fill from start
Volume
64%
64%
range — two thumbs · fill between
Estimate (points)
9 – 24
9
24
stepped — snap to notch · labelled axis
Sprint length
5 wk
5 wk
1 wk5 wk8 wk

Examples

Sliders stack cleanly in settings panels and filter sidebars — each row pairs a label with a live readout, so a glance covers every value.

Display
Brightness
72%
72%
Contrast
48%
48%
Card density
3
3
135
Filters
Budget
25k – 70k
25k
70k
Team size
12 – 29
12
29
Min. progress
60%
60%

Value bubble

A bubble with the exact formatted value surfaces above the active thumb while it is dragged or keyboard-focused, then fades out. Format it with the unit and decimals props.

Drag the thumb or focus it with Tab to surface the bubble
Opacity
35%
35%
Zoom
2.0x
2.0x

States

The thumb grows a soft focus ring when active or keyboard-focused, and the whole control dims and locks when disabled.

default
Threshold
55%
55%
disabled
Threshold
55%
55%

Props

PropTypeDefaultDescription
variant"single" | "range" | "stepped""single"One thumb, two thumbs with a fill between, or a single thumb that snaps to visible tick marks with a labelled axis.
labelstring"Value"Label in the header row; also names the thumbs for assistive tech.
showHeaderbooleantrueShow the label + live readout row above the track.
minnumber0Minimum allowed value.
maxnumber100Maximum allowed value.
stepnumber1Granularity — values snap to multiples of the step.
unitstring""Suffix appended to formatted values, e.g. "%" or "k".
decimalsnumber0Decimal places in the readout and bubble; 0 rounds to integers.
valuenumber | [number, number]Controlled value. Use a [lo, hi] pair for range.
defaultValuenumber | [number, number]Uncontrolled initial value. Defaults to the midpoint (single/stepped) or the 25–70% span (range).
onValueChange(value) => voidFires on every change while dragging or nudging.
onValueCommitted(value) => voidFires once when a drag or key interaction settles.
scalenumber[][min, mid, max]Axis labels under a stepped slider.
disabledbooleanfalseDims the control and blocks pointer and keyboard input.
namestringForm field name, submitted via the hidden range input.
…restHTMLAttributesEverything else is forwarded to the root <div>, including ref.

Usage

Do

Use for approximate values

Volume, opacity, a price band — where “about here” is the point and fine precision is not required.

Don’t

Use for exact, sparse choices

For 3–4 discrete options a segmented control or radios are faster and clearer than a stepped slider.

Do

Always show the value

A live readout or bubble turns a vague position into a concrete, trustworthy number.

Quality
80%
80%
Don’t

Hide it on tiny ranges

A slider needs travel. For a 0–3 range a number stepper gives bigger, surer hit targets.

Keyboard & accessibility

Each thumb renders a native range input with role slider plus aria value, min and max. Tab focuses thumbs in order and shows the ring. Arrow keys nudge by one step (Shift+Arrow and PageUp/PageDown by a larger step); Home and End jump to the ends. The fill and thumb clear 3:1 against the track and surface.

Tab to a thumb, then use the arrow keys
Playback speed
100%
100%
Working hours
6h – 17h
6h
17h