Slider

Accessible React slider for a single value or a two-thumb range, with a live readout, custom formatting, sizes, and field wiring. Keyboard and RTL ready.

Pass a number for one thumb or number[] for a range. showValue adds a live readout and formatValue shapes it.

When to use

Use Slider when the exact number matters less than its position in a range, such as a budget bracket or a satisfaction score. Pass an array for a two-thumb range. If users must enter a precise value, pair it with NumberInput or use NumberInput alone.

Turn on showValue so the current value is visible without guessing.

Examples

Single value with readout

Range (two thumbs)

Percentage format

Small and disabled

Props

Props declared by Slider. Native attributes of the underlying element pass through.

PropTypeDefaultDescription
valueSliderValueControlled value. number → single thumb, number[] → one thumb each.
defaultValueSliderValueUncontrolled initial value. Defaults to a single thumb at min.
onValueChange(value: SliderValue) => voidFires continuously while dragging. Shape mirrors value/defaultValue.
onValueCommit(value: SliderValue) => voidFires once on release (pointer up / keyboard commit).
labelreact.ReactNodeVisible field label, associated to the thumb(s) via aria-labelledby.
helperTextreact.ReactNodeHint shown below the field. Hidden while an error message is showing.
errorMessagereact.ReactNodeMessage shown below the field when error is true.
errorbooleanMarks the field invalid: sets aria-invalid and error styling.
size"sm" | "md"Control size. Scales rail, thumb, label, and helper text. Defaults to md.
showValuebooleanRender the current value(s) as text beside the label.
formatValue(value: number) => stringFormats each value for showValue and the thumb's aria-valuetext (e.g. percentages or currency).
thumbLabels[string, string]Accessible names for the two range thumbs. Ignored for single thumbs. Defaults to ['Minimum', 'Maximum'].
namestring
disabledboolean
orientation"vertical" | "horizontal"
dirDirection
minnumber
maxnumber
stepnumber
minStepsBetweenThumbsnumber
invertedboolean
formstring

Accessibility

Each thumb is a slider role with the current value exposed and aria-valuetext from formatValue, so a screen reader hears "25 percent" rather than a raw number. Arrow keys move by step, Page Up and Page Down move faster, and Home and End jump to the limits.

Name multiple thumbs with thumbLabels. The track flips in RTL so the arrow keys still feel natural.