Slider

An easily stylable range input.

API reference

Import the component and place its parts the following way:

Anatomy
import { Slider } from '@base-ui-components/react/slider';

<Slider.Root>
  <Slider.Value />
  <Slider.Control>
    <Slider.Track>
      <Slider.Indicator />
      <Slider.Thumb />
    </Slider.Track>
  </Slider.Control>
</Slider.Root>

Root

Groups all parts of the slider. Renders a <div> element.

PropTypeDefault
aria-labelledbystringundefined
classNamestring | (state) => stringundefined
defaultValueArray<number> | numberundefined
disabledbooleanfalse
formatIntl.NumberFormatOptionsundefined
largeStepnumber10
maxnumber100
minnumber0
minStepsBetweenValuesnumber0
namestringundefined
onValueChange(value, event, activeThumbIndex) => voidundefined
onValueCommitted(value, event) => voidundefined
orientation'horizontal' | 'vertical''horizontal'
render| React.ReactElement
| (props, state) => React.ReactElement
undefined
stepnumber1
valueArray<number> | numberundefined
Attribute
Description
data-dirty
data-disabled
data-dragging
data-invalid
data-orientation
data-readonly
data-required
data-touched
data-valid

Value

Displays the current value of the slider as text. Renders an <output> element.

PropTypeDefault
children| React.ReactNode
| (formattedValue, value) => React.ReactNode
undefined
classNamestring | (state) => stringundefined
render| React.ReactElement
| (props, state) => React.ReactElement
undefined
Attribute
Description
data-dirty
data-disabled
data-dragging
data-invalid
data-orientation
data-readonly
data-required
data-touched
data-valid

Control

The clickable, interactive part of the slider. Renders a <div> element.

PropTypeDefault
classNamestring | (state) => stringundefined
render| React.ReactElement
| (props, state) => React.ReactElement
undefined
Attribute
Description
data-dirty
data-disabled
data-dragging
data-invalid
data-orientation
data-readonly
data-required
data-touched
data-valid

Track

Contains the slider indicator and represents the entire range of the slider. Renders a <div> element.

PropTypeDefault
classNamestring | (state) => stringundefined
render| React.ReactElement
| (props, state) => React.ReactElement
undefined
Attribute
Description
data-dirty
data-disabled
data-dragging
data-invalid
data-orientation
data-readonly
data-required
data-touched
data-valid

Indicator

Visualizes the current value of the slider. Renders a <div> element.

PropTypeDefault
classNamestring | (state) => stringundefined
render| React.ReactElement
| (props, state) => React.ReactElement
undefined
Attribute
Description
data-dirty
data-disabled
data-dragging
data-invalid
data-orientation
data-readonly
data-required
data-touched
data-valid

Thumb

The draggable part of the the slider at the tip of the indicator. Renders a <div> element.

PropTypeDefault
aria-labelstringundefined
aria-valuetextstringundefined
classNamestring | (state) => stringundefined
getAriaLabelfunction(index: number) => stringundefined
getAriaValueTextfunction(formattedValue: string, value: number, index: number) => stringundefined
render| React.ReactElement
| (props, state) => React.ReactElement
undefined
Attribute
Description
data-dirty
data-disabled
data-dragging
data-invalid
data-orientation
data-readonly
data-required
data-touched
data-valid