Skip to content

Slider

A track and thumb that picks a number or range by dragging.

Temperature
0.7
PreciseCreative
hero.tsx

Usage guidelines

  • Use Slider for a number or range picked by dragging, where the approximate position matters more than an exact value. Use NumberField for exact numbers.
  • Name the slider with SliderLabel. In a range slider, also give each SliderThumb an aria-label so the two thumbs are distinguishable.
  • Show the current value with SliderValue when the number matters to the decision. Format it with the root format option rather than formatting text by hand, and pass the app language to locale; without it, units and separators follow the browser's runtime locale.
  • Set step to the precision the value needs; keyboard and pointer changes snap to it. largeStep sets the jump for PageUp, PageDown and Shift with an arrow key. It defaults to 10, so set it for small ranges.
  • Pass a tuple to value or defaultValue for a range and type the root, such as Slider<readonly [number, number]>, so onValueChange receives the same shape.

Anatomy

tsx
tsx

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.

Latency
2s – 8s
range.tsx

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.

Score threshold
0.50

Applied threshold: 0.50

committed.tsx

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.

Top K
3

Set by the knowledge base retrieval settings.

disabled.tsx

Keyboard

KeyAction
Right arroworUp arrowIncreases the focused thumb by one step.
Left arroworDown arrowDecreases the focused thumb by one step.
Shift + arrow keyChanges the focused thumb by largeStep.
PageUporPageDownIncreases or decreases by largeStep.
HomeorEndMoves the focused thumb to the minimum or maximum. A range thumb stops at the other thumb.
TabMoves 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.

Base UI Slider.Root docs

Data attributes
AttributeDescription
data-dragging

Present while the user is dragging.

data-orientation

Values: 'horizontal' | 'vertical'

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.

Base UI Slider.Control docs

Data attributes
AttributeDescription
data-dragging

Present while the user is dragging.

data-orientation

Values: 'horizontal' | 'vertical'

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.

Base UI Slider.Indicator docs

Data attributes
AttributeDescription
data-dragging

Present while the user is dragging.

data-orientation

Values: 'horizontal' | 'vertical'

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.

Base UI Slider.Label docs

Data attributes
AttributeDescription
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: number

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: number

The maximum value.

data-min

Values: number

The minimum value.

data-minstepsbetweenvalues

Values: number

The minimum steps between values in a range slider.

data-orientation

Values: 'horizontal' | 'vertical'

The component orientation.

data-step

Values: number

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">.

Base UI Slider.Thumb docs

Data attributes
AttributeDescription
data-index

Indicates the index of the thumb in range sliders.

data-dragging

Present while the user is dragging.

data-orientation

Values: 'horizontal' | 'vertical'

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.

Base UI Slider.Track docs

Data attributes
AttributeDescription
data-dragging

Present while the user is dragging.

data-orientation

Values: 'horizontal' | 'vertical'

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.

Base UI Slider.Value docs

Data attributes
AttributeDescription
data-dragging

Present while the user is dragging.

data-orientation

Values: 'horizontal' | 'vertical'

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).