Slider
Picks a value from a range. A thick rounded track and a slim handle with breathing room on both sides; press it and the handle thins, drag it and a bubble shows the value.
Install
npx shadcn@latest add @nelumbo/sliderBasic
The dot at the end of the track marks where it stops. Tab to the handle and use the arrow keys; Page Up and Down move in bigger steps.
Range
Pass two values for a range. Each handle is announced as the minimum or the maximum.
Steps
With marks, a dot shows every step. Use it for a handful of choices, not for fine steps.
Large, with an icon
The lg size is made for media and device controls. The icon sits inside the filled part, and moves past the handle when there is no room.
Brand color
For a slider that should carry the accent.
In a form
Show the value next to the title so it reads at a glance, and pass formatValue so screen readers hear the same text.
Usage
import { Slider } from "@/components/ui/slider"<Slider aria-label="Volume" defaultValue={[40]} valueLabel /><Slider aria-label="Price" max={600} step={10} value={range} onValueChange={setRange} formatValue={(v) => `$${v}`}/><Slider size="lg" icon="volume_up" aria-label="Media volume" />Props
Other props go to Radix Slider (value, defaultValue, onValueChange, onValueCommit, min, max, step, minStepsBetweenThumbs, name…).
| Prop | Type | Default | Notes |
|---|---|---|---|
size | "default" | "lg" | "default" | 16px or 40px track |
color | "auto" | "neutral" | "brand" | "auto" | |
marks | boolean | false | A dot for every step |
valueLabel | boolean | false | Bubble with the value while dragging or focused |
formatValue | (value: number) => string | String | Used by the bubble and as aria-valuetext |
icon | IconName | lg only, single value |