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-label and aria-labelledby for labeling
  • Focus states are clearly visible

API Reference

Slider Props

PropTypeDefaultDescription
valuenumber-Controlled value (single mode)
defaultValuenumber-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
showTooltipbooleanfalseShow percentage tooltip above thumb(s)
minnumber0Minimum value
maxnumber100Maximum value
stepnumber1Step increment
disabledbooleanfalseWhether the slider is disabled
classNamestring-Additional CSS classes