Slider

Slider is an input control for selecting a value within a specified range. Supports both single value selection and range selection.

Tooltip
Labels
3
Sizes
S/R
Mode
Radix
Base

Playground

Preview
Dsingle
Size
Color
Mode
Step
Direction
Tooltip
Options
<Slider
  defaultValue={[50]}
/>

Sizes

sm
Track4px
Thumb14px
default
Track6px
Thumb18px
lg
Track8px
Thumb22px

Features

Range

Pass two values to defaultValue to use as a range slider.

<Slider defaultValue={[25, 75]} />

With Value

Pattern for displaying the value in controlled mode.

50
const [value, setValue] = useState([50])

<div className="space-y-4">
  <div className="text-center">
    <span className="text-2xl font-bold text-foreground tabular-nums">{value[0]}</span>
  </div>
  <Slider value={value} onValueChange={setValue} />
</div>

States

Default
Disabled
<Slider defaultValue={[50]} />
<Slider defaultValue={[50]} disabled />

API

Props

valueundefined
number[]

Value in controlled mode (array)

defaultValueundefined
number[]

Initial value in uncontrolled mode (array)

onValueChangeundefined
(value: number[]) => void

Callback when value changes (fires during drag)

onValueCommitundefined
(value: number[]) => void

Callback when drag is complete

color"default"
"default" | "primary"

Color of the range and thumb

size"default"
"sm" | "default" | "lg"

Slider size

min0
number

Minimum value

max100
number

Maximum value

step1
number

Step value

minStepsBetweenThumbs0
number

Minimum steps between thumbs in range mode

showTooltip"never"
"auto" | "always" | "never"

Tooltip display mode. auto shows on hover/drag

formatLabelundefined
(value: number) => string

Format function for tooltip value

startContentundefined
ReactNode

Content displayed on the left side of the slider (icon, label, etc.)

endContentundefined
ReactNode

Content displayed on the right side of the slider

disabledfalse
boolean

Disabled state

orientation"horizontal"
"horizontal" | "vertical"

Layout direction

invertedfalse
boolean

Invert the value direction

nameundefined
string

Form name attribute

Customization

Pass a ReactNode to startContent / endContent to freely customize styles.

With Icon

startContent={<VolumeOff />} endContent={<Volume2 />}

Styled Labels

$0$100
startContent={<span className="text-xs font-mono font-bold text-primary">$0</span>} endContent={<span className="text-xs font-mono font-bold text-primary">$100</span>}

Icon + Tooltip

<Slider showTooltip="always" formatLabel={(v) => `${v}%`} startContent={<Sun />} endContent={<Sun />} />

Tip:startContent / endContent accept any ReactNode — strings, icons, or custom components. Font size auto-adjusts to match the Slider size.

Anatomy

1
60
2
3
050100
Track height6px
Thumb size18px
1
Track
Full range of the slider
2
Range
Selected value range
3
Thumb
Draggable handle

Best Practices

Do

  • Display the current value nearby
  • Set an appropriate step value
  • Use range mode for range selection
  • Clearly define the min/max range

Don't

  • Use Input instead for precise value entry
  • Avoid extremely small step values
  • Don't use without showing the current value
  • Avoid sliders that are too narrow on mobile

Accessibility

Keyboard Navigation

← →Increase/decrease by 1 step
↑ ↓Increase/decrease by 1 step
HomeMove to minimum value
EndMove to maximum value

ARIA Attributes

  • role="slider" auto-applied
  • aria-valuemin/max/now auto-managed
  • Focus indicator
  • Touch support