Demos

A controlled slider with its value shown beside the label.

Usage

Use a slider when the exact number matters less than its position in a range, such as average sleep or a target band. When the reader needs an exact value, use an Input, or show the value next to the slider.

Import it from @workspace/ui/components/slider.

Anatomy

  • Slider — Track, filled range, and one thumb per value.

Notes

  • Always pass defaultValue or value as an array. One item gives one thumb, two items give a range.
  • Every slider needs a name. Point aria-labelledby at a visible label. aria-label on the slider only names the outer group, not the thumbs.
  • Arrow keys move by step. Page Up and Page Down move by larger steps.

Examples

Range

Pass two values to get two thumbs.

Disabled

A slider the reader can see but not move.

Props

These are the props you set most often. Unlisted props pass through to the underlying element.

Slider

PropTypeDefaultDescription
defaultValuenumber[]—Value on first render.
valuenumber[]—Value when controlled.
onValueChange(value) => void—Called while the value changes. value is a number or an array.
onValueCommitted(value) => void—Called once when the reader lets go.
minnumber0Lowest value.
maxnumber100Highest value.
stepnumber1Amount each step moves.
largeStepnumber10Amount Page Up and Page Down move.
orientation"horizontal" or "vertical"horizontalDirection of the track.
disabledbooleanfalseBlocks input and dims the slider.