Slider
A track and thumb that picks a number or range by dragging.
Usage guidelines
- Use
Sliderfor a number or range picked by dragging, where the approximate position matters more than an exact value. UseNumberFieldfor exact numbers. - Name the slider with
SliderLabel. In a range slider, also give eachSliderThumbanaria-labelso the two thumbs are distinguishable. - Show the current value with
SliderValuewhen the number matters to the decision. Format it with the rootformatoption rather than formatting text by hand, and pass the app language tolocale; without it, units and separators follow the browser's runtime locale. - Set
stepto the precision the value needs; keyboard and pointer changes snap to it.largeStepsets the jump forPageUp,PageDownandShiftwith an arrow key. It defaults to10, so set it for small ranges. - Pass a tuple to
valueordefaultValuefor a range and type the root, such asSlider<readonly [number, number]>, soonValueChangereceives the same shape.
Anatomy
SliderControl is the pointer area, SliderIndicator fills the selected part of the track, and each SliderThumb renders a native range input.
Examples
Range
Render one SliderThumb per value with its index and an aria-label. SliderValue shows both ends, formatted by format in the given locale.
Commit on release
Use onValueCommitted to trigger expensive work such as re-querying retrieval results only after the pointer is released or a keyboard step finishes, while SliderValue updates live during the drag.
Applied threshold: 0.50
Disabled
Set disabled on Field (or on Slider directly) to dim the slider and block pointer and keyboard input. Keep FieldDescription on the field to explain why it is locked; it stays readable and becomes the thumb's accessible description.
Set by the knowledge base retrieval settings.
Keyboard
| Key | Action |
|---|---|
| Right arroworUp arrow | Increases the focused thumb by one step. |
| Left arroworDown arrow | Decreases the focused thumb by one step. |
Shift + arrow key | Changes the focused thumb by largeStep. |
| PageUporPageDown | Increases or decreases by largeStep. |
| HomeorEnd | Moves the focused thumb to the minimum or maximum. A range thumb stops at the other thumb. |
| Tab | Moves focus between thumbs, then out of the slider. |
API reference
Slider
Groups all parts of a single-value or range slider. Renders a <div> element.
| Prop | Type | Default | Details |
|---|---|---|---|
style | React.CSSProperties | ((state: SliderRootState) => React.CSSProperties | undefined) | No default | |
defaultValue | Value | No default | |
disabled | boolean | false | |
format | Intl.NumberFormatOptions | No default | |
locale | Intl.LocalesArgument | No default | |
max | number | 100 | |
min | number | 0 | |
minStepsBetweenValues | number | 0 | |
name | string | No default | |
form | string | No default | |
orientation | 'horizontal' | 'vertical' | 'horizontal' | |
step | number | 1 | |
largeStep | number | 10 | |
thumbAlignment | 'center' | 'edge' | 'edge-client-only' | 'center' | |
thumbCollisionBehavior | 'none' | 'push' | 'swap' | 'push' | |
value | Value | No default | |
onValueChange | ((value: Value extends number ? number : Value, eventDetails: BaseSlider.Root.ChangeEventDetails) => void) | No default | |
onValueCommitted | ((value: Value extends number ? number : Value, eventDetails: BaseSlider.Root.CommitEventDetails) => void) | No default | |
className | string | ((state: SliderRootState) => string | undefined) | No default | |
render | ComponentRenderFn<HTMLProps, SliderRootState> | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | No default | |
| Attribute | Description |
|---|---|
data-dragging | Present while the user is dragging. |
data-orientation | Values: Indicates the orientation of the slider. |
data-disabled | Present when the slider is disabled. |
data-valid | Present when the slider is in a valid state (when wrapped in Field.Root). |
data-invalid | Present when the slider is in an invalid state (when wrapped in Field.Root). |
data-touched | Present when the slider has been touched (when wrapped in Field.Root). |
data-dirty | Present when the slider's value has changed (when wrapped in Field.Root). |
data-focused | Present when the slider is focused (when wrapped in Field.Root). |
SliderControl
The clickable, interactive part of the slider. Renders a <div> element.
| Prop | Type | Default | Details |
|---|---|---|---|
className | string | ((state: SliderControlState) => string | undefined) | No default | |
render | ComponentRenderFn<HTMLProps, SliderControlState> | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | No default | |
style | React.CSSProperties | ((state: SliderControlState) => React.CSSProperties | undefined) | No default | |
| Attribute | Description |
|---|---|
data-dragging | Present while the user is dragging. |
data-orientation | Values: Indicates the orientation of the slider. |
data-disabled | Present when the slider is disabled. |
data-valid | Present when the slider is in a valid state (when wrapped in Field.Root). |
data-invalid | Present when the slider is in an invalid state (when wrapped in Field.Root). |
data-touched | Present when the slider has been touched (when wrapped in Field.Root). |
data-dirty | Present when the slider's value has changed (when wrapped in Field.Root). |
data-focused | Present when the slider is focused (when wrapped in Field.Root). |
SliderIndicator
Visualizes the current value of the slider. Renders a <div> element.
| Prop | Type | Default | Details |
|---|---|---|---|
className | string | ((state: SliderIndicatorState) => string | undefined) | No default | |
render | ComponentRenderFn<HTMLProps, SliderIndicatorState> | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | No default | |
style | React.CSSProperties | ((state: SliderIndicatorState) => React.CSSProperties | undefined) | No default | |
| Attribute | Description |
|---|---|
data-dragging | Present while the user is dragging. |
data-orientation | Values: Indicates the orientation of the slider. |
data-disabled | Present when the slider is disabled. |
data-valid | Present when the slider is in a valid state (when wrapped in Field.Root). |
data-invalid | Present when the slider is in an invalid state (when wrapped in Field.Root). |
data-touched | Present when the slider has been touched (when wrapped in Field.Root). |
data-dirty | Present when the slider's value has changed (when wrapped in Field.Root). |
data-focused | Present when the slider is focused (when wrapped in Field.Root). |
SliderLabel
An accessible label that is automatically associated with the slider thumbs. Renders a <div> element.
| Prop | Type | Default | Details |
|---|---|---|---|
className | string | ((state: SliderRootState) => string | undefined) | No default | |
render | ComponentRenderFn<HTMLProps, SliderRootState> | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | No default | |
style | React.CSSProperties | ((state: SliderRootState) => React.CSSProperties | undefined) | No default | |
| Attribute | Description |
|---|---|
data-touched | Present when the field has been touched. |
data-dirty | Present when the field value has changed from its initial value. |
data-filled | Present when the field has a value. |
data-focused | Present when the field is focused. |
data-activethumbindex | Values: The index of the active thumb. |
data-disabled | Present when the component should ignore user interaction. |
data-dragging | Present when the thumb is currently being dragged. |
data-max | Values: The maximum value. |
data-min | Values: The minimum value. |
data-minstepsbetweenvalues | Values: The minimum steps between values in a range slider. |
data-orientation | Values: The component orientation. |
data-step | Values: The step increment of the slider when incrementing or decrementing. It will snap to multiples of this value. Decimal values are supported. |
SliderThumb
The draggable part of the slider at the tip of the indicator. Renders a <div> element and a nested <input type="range">.
| Prop | Type | Default | Details |
|---|---|---|---|
disabled | boolean | false | |
aria-valuetext | string | No default | |
getAriaLabel | ((index: number) => string) | null | No default | |
getAriaValueText | ((formattedValue: string, value: number, index: number) => string) | null | No default | |
index | number | No default | |
inputRef | React.Ref<HTMLInputElement> | No default | |
tabIndex | number | No default | |
className | string | ((state: SliderThumbState) => string | undefined) | No default | |
render | ComponentRenderFn<HTMLProps, SliderThumbState> | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | No default | |
style | React.CSSProperties | ((state: SliderThumbState) => React.CSSProperties | undefined) | No default | |
| Attribute | Description |
|---|---|
data-index | Indicates the index of the thumb in range sliders. |
data-dragging | Present while the user is dragging. |
data-orientation | Values: Indicates the orientation of the slider. |
data-disabled | Present when the slider is disabled. |
data-valid | Present when the slider is in a valid state (when wrapped in Field.Root). |
data-invalid | Present when the slider is in an invalid state (when wrapped in Field.Root). |
data-touched | Present when the slider has been touched (when wrapped in Field.Root). |
data-dirty | Present when the slider's value has changed (when wrapped in Field.Root). |
data-focused | Present when the slider is focused (when wrapped in Field.Root). |
SliderTrack
Contains the slider indicator and represents the entire range of the slider. Renders a <div> element.
| Prop | Type | Default | Details |
|---|---|---|---|
className | string | ((state: SliderTrackState) => string | undefined) | No default | |
render | ComponentRenderFn<HTMLProps, SliderTrackState> | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | No default | |
style | React.CSSProperties | ((state: SliderTrackState) => React.CSSProperties | undefined) | No default | |
| Attribute | Description |
|---|---|
data-dragging | Present while the user is dragging. |
data-orientation | Values: Indicates the orientation of the slider. |
data-disabled | Present when the slider is disabled. |
data-valid | Present when the slider is in a valid state (when wrapped in Field.Root). |
data-invalid | Present when the slider is in an invalid state (when wrapped in Field.Root). |
data-touched | Present when the slider has been touched (when wrapped in Field.Root). |
data-dirty | Present when the slider's value has changed (when wrapped in Field.Root). |
data-focused | Present when the slider is focused (when wrapped in Field.Root). |
SliderValue
Displays the current value of the slider as text. Renders an <output> element.
| Prop | Type | Default | Details |
|---|---|---|---|
children | ((formattedValues: readonly string[], values: readonly number[]) => React.ReactNode) | null | No default | |
className | string | ((state: SliderValueState) => string | undefined) | No default | |
render | ComponentRenderFn<HTMLProps, SliderValueState> | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | No default | |
style | React.CSSProperties | ((state: SliderValueState) => React.CSSProperties | undefined) | No default | |
| Attribute | Description |
|---|---|
data-dragging | Present while the user is dragging. |
data-orientation | Values: Indicates the orientation of the slider. |
data-disabled | Present when the slider is disabled. |
data-valid | Present when the slider is in a valid state (when wrapped in Field.Root). |
data-invalid | Present when the slider is in an invalid state (when wrapped in Field.Root). |
data-touched | Present when the slider has been touched (when wrapped in Field.Root). |
data-dirty | Present when the slider's value has changed (when wrapped in Field.Root). |
data-focused | Present when the slider is focused (when wrapped in Field.Root). |