Slider
Sliders allow users to select a value or range from a continuous scale. Built on top of Radix UI primitives for accessibility.
Basic Usage
import { Slider } from '@/components'
<Slider defaultValue={60} />With Tooltip
Show a percentage tooltip above the thumb when dragging.
<Slider defaultValue={60} showTooltip />Range Slider
Use a range slider to select a range of values with two thumbs.
<Slider defaultRangeValue={[30, 60]} />Range with Tooltip
<Slider defaultRangeValue={[30, 60]} showTooltip />Disabled
Disabled sliders cannot be interacted with and display a muted appearance.
Disabled single value
Disabled range
<Slider defaultValue={50} disabled />
<Slider defaultRangeValue={[25, 75]} disabled />Controlled
You can control the slider value externally using controlled props.
Single Value
Current value: 50
const [value, setValue] = useState(50)
<Slider
value={value}
onValueChange={setValue}
showTooltip
/>Range
Range: 20 - 80
const [value, setValue] = useState<[number, number]>([20, 80])
<Slider
rangeValue={value}
onRangeValueChange={setValue}
showTooltip
/>Custom Range
Customize the min, max, and step values.
Min: 0, Max: 1000, Step: 50
<Slider
defaultValue={500}
min={0}
max={1000}
step={50}
showTooltip
/>All Variants
Single Value
Single Value with Tooltip
Range
Range with Tooltip
Accessibility
- Built on Radix UI Slider primitive for robust accessibility
- Full keyboard support (Arrow keys, Home, End)
- Proper ARIA attributes for screen readers
- Supports
aria-labelandaria-labelledbyfor labeling - Focus states are clearly visible
API Reference
Slider Props
| Prop | Type | Default | Description |
|---|---|---|---|
| value | number | - | Controlled value (single mode) |
| defaultValue | number | - | Default value (single mode, uncontrolled) |
| onValueChange | (value: number) => void | - | Callback when value changes (single mode) |
| rangeValue | [number, number] | - | Controlled value (range mode) |
| defaultRangeValue | [number, number] | - | Default value (range mode, uncontrolled) |
| onRangeValueChange | (value: [number, number]) => void | - | Callback when range changes |
| showTooltip | boolean | false | Show percentage tooltip above thumb(s) |
| min | number | 0 | Minimum value |
| max | number | 100 | Maximum value |
| step | number | 1 | Step increment |
| disabled | boolean | false | Whether the slider is disabled |
| className | string | - | Additional CSS classes |