Slider

An easily stylable range input.

API reference

Import the component and assemble its parts:

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-labelledby

string

undefined

name

string

undefined

defaultValue

Array<number> | number

undefined

value

Array<number> | number

undefined

onValueChange

(value, event, activeThumbIndex) => void

undefined

onValueCommitted

(value, event) => void

undefined

step

number

1

largeStep

number

10

minStepsBetweenValues

number

0

min

number

0

max

number

100

format

Intl.NumberFormatOptions

undefined

disabled

boolean

false

orientation

'horizontal' | 'vertical'

'horizontal'

className

string | (state) => string

undefined

render

| React.ReactElement
| (props, state) => React.ReactElement

undefined

Attribute
Description
data-dragging
data-orientation
data-disabled
data-readonly
data-required
data-valid
data-invalid
data-dirty
data-touched

Value

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

PropTypeDefault
children

| React.ReactNode
| (formattedValue, value) => React.ReactNode

undefined

className

string | (state) => string

undefined

render

| React.ReactElement
| (props, state) => React.ReactElement

undefined

Attribute
Description
data-dragging
data-orientation
data-disabled
data-readonly
data-required
data-valid
data-invalid
data-dirty
data-touched

Control

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

PropTypeDefault
className

string | (state) => string

undefined

render

| React.ReactElement
| (props, state) => React.ReactElement

undefined

Attribute
Description
data-dragging
data-orientation
data-disabled
data-readonly
data-required
data-valid
data-invalid
data-dirty
data-touched

Track

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

PropTypeDefault
className

string | (state) => string

undefined

render

| React.ReactElement
| (props, state) => React.ReactElement

undefined

Attribute
Description
data-dragging
data-orientation
data-disabled
data-readonly
data-required
data-valid
data-invalid
data-dirty
data-touched

Indicator

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

PropTypeDefault
className

string | (state) => string

undefined

render

| React.ReactElement
| (props, state) => React.ReactElement

undefined

Attribute
Description
data-dragging
data-orientation
data-disabled
data-readonly
data-required
data-valid
data-invalid
data-dirty
data-touched

Thumb

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

PropTypeDefault
aria-label

string

undefined

aria-valuetext

string

undefined

getAriaLabel

function(index: number) => string

undefined

getAriaValueText

function(formattedValue: string, value: number, index: number) => string

undefined

className

string | (state) => string

undefined

render

| React.ReactElement
| (props, state) => React.ReactElement

undefined

Attribute
Description
data-dragging
data-orientation
data-disabled
data-readonly
data-required
data-valid
data-invalid
data-dirty
data-touched