Slider

Forms
Input

Interactive slider with single value or range selection. Ideal for volume controls, price ranges, and numeric settings.

Preview

Drag the slider to adjust values

65

Variants

Single value and range selection modes

Single Value (default)

65

Range Selection

20 - 80

With Min/Max Labels

Display minimum and maximum values

75

Custom Step

Control step increments

Step: 0.5

3

Step: 25

50

Custom Range

Set custom min and max values

Price ($100-$5000)

500

Temperature (-20°C to 50°C)

22

States

Different states for various use cases

Default

50

Disabled

50

Props

Slider component API reference

PropTypeDefaultDescription
valuenumberCurrent slider value (controlled)
defaultValuenumber50Initial value (uncontrolled)
onChange(value: number) => voidCallback when value changes
minnumber0Minimum value
maxnumber100Maximum value
stepnumber1Step increment
labelstringLabel text
showValuebooleantrueDisplay current value
showMinMaxbooleanfalseDisplay min/max labels
disabledbooleanfalseDisable interaction
variant'default' | 'range''default'Slider type
rangeValue[number, number]Range values (for range variant)
onRangeChange(value: [number, number]) => voidRange change callback

Usage

Import and implementation example

import { Slider } from '@/components/ui/slider'

export default function Example() {
  const [value, setValue] = useState(50)
  const [range, setRange] = useState<[number, number]>([20, 80])

  return (
    <>
      {/* Basic slider */}
      <Slider
        value={value}
        onChange={setValue}
        label="Volume"
        showValue
      />

      {/* Range slider */}
      <Slider
        variant="range"
        rangeValue={range}
        onRangeChange={setRange}
        min={0}
        max={1000}
        step={10}
      />

      {/* With custom range and step */}
      <Slider
        label="Temperature"
        min={-20}
        max={50}
        step={5}
        showMinMax
      />

      {/* With labels */}
      <Slider
        label="Brightness"
        defaultValue={75}
        showValue
        showMinMax
      />
    </>
  )
}

Features

Built-in functionality

  • Single & range modes: Select single value or range with two thumbs
  • Custom step: Integer or decimal step increments
  • Custom range: Set min and max boundaries
  • Value display: Show current value and min/max labels
  • Drag interaction: Smooth drag behavior on track and thumb
  • Click to set: Click anywhere on track to set value
  • Controlled mode: Support for controlled and uncontrolled usage
  • Dark mode: Full dark mode support

Accessibility

Accessibility considerations

ARIA Attributes

Uses role="slider" for thumb elementsaria-valuemin, aria-valuemax, aria-valuenowaria-orientation indicates horizontal layout

Keyboard Navigation

KeyAction
TabFocus the slider thumb
Arrow Left/RightDecrease/increase by step
HomeSet to minimum value
EndSet to maximum value

Notes

  • Label properly associated with slider
  • Value announced on change
  • Disabled state prevents interaction
  • Focus ring visible on keyboard focus

Related Components