Slider
An input where the user selects a value from within a given range.
Installation
bash
npx shadcn@latest add @redpanda/sliderbash
pnpm dlx shadcn@latest add @redpanda/sliderbash
yarn dlx shadcn@latest add @redpanda/sliderbash
bunx shadcn@latest add @redpanda/sliderbash
nubx shadcn@latest add @redpanda/sliderbash
aube dlx shadcn@latest add @redpanda/sliderRange
Vertical orientation
Disabled
Live value label
Custom step increments
Formatted value
Drag bubble
Custom min, max, and step
When to use
Sliders allow users to select a value from a range. Use this decision tree:
Usage
tsx
import { Slider } from '@/components/ui/slider';tsx
<Slider defaultValue={[33]} max={100} step={1} />Props
Keyboard interactions
| Key | Action |
|---|---|
Tab to thumb |
Focus lands on the thumb. Range sliders have one thumb per value. |
ArrowLeft / ArrowDown |
Decreases value by one step. |
ArrowRight / ArrowUp |
Increases value by one step. |
PageDown / PageUp |
Decreases / increases by a larger step (roughly 10% of the range). |
Home / End |
Jumps to min / max. |
Accessibility
- Each thumb exposes
role="slider"witharia-valuemin,aria-valuemax, andaria-valuenow. Always provide a programmatic label (<Label>+aria-labelledby, oraria-label) describing what the value represents. - Pair the slider with a visible numeric value where precision matters — sliders alone are hard to read for screen-reader and low-vision users.
onValueChangereceivesnumber[](always an array, even for single-thumb sliders) — unwrap withvalue[0]when you only need a scalar.- Range sliders enforce
minValue[i] <= value[i] <= value[i+1] <= maxValueautomatically; you don’t need to clamp in user land.