Slider
An input where the user selects a value from within a given range.
Pair with Field.* for description/error wiring in forms. Pass aria-label to Slider so the rendered thumb has an accessible name:
Drag to adjust playback volume.
Or render the control on its own:
Examples
With TanStack Form
Use @tanstack/react-form with zod to keep a single-thumb slider controlled. Radix emits slider values as an array, so pass the first value into field.handleChange.
Single thumb
A basic slider with a single thumb for selecting a single value. You can pass a single number instead of an array.
Range
Use two values to create a range slider with two thumbs.
Multiple thumbs
Use more than two values to create a slider with multiple thumbs.
Color
Use the color prop to change the color of the slider range. Accepts any Tailwind bg-* class.
Ticks
Use the showTicks prop to show tick marks along the track, one per step, spread evenly. When the range is not a multiple of step, the ticks do not land on the step values.
API Reference
Slider
The Slider is built on top of Radix Slider. It accepts all props from the Radix Slider Root component.
defaultValue and value both accept number | number[], but they must be the same type — you cannot mix a single number with a number[].