Skip to content
+

Slider

The Slider component provides users with an input for a one or more numerical values within a given range.

SliderControl API

Import

import * as Slider from '@base_ui/react/Slider';
const SliderControl = Slider.Control;

Props

Props of the native component are also available.

NameTypeDescription
classNamefunc
| string

Class names applied to the element or a function that returns them based on the component's state.

renderelement
| func

A function to customize rendering of the component.


The ref is forwarded to the root element.

Theme default props

You can use SliderControl to change the default props of this component with the theme.

SliderIndicator API

Import

import * as Slider from '@base_ui/react/Slider';
const SliderIndicator = Slider.Indicator;

Props

Props of the native component are also available.

NameTypeDescription
classNamefunc
| string

Class names applied to the element or a function that returns them based on the component's state.

renderelement
| func

A function to customize rendering of the component.


The ref is forwarded to the root element.

Theme default props

You can use SliderIndicator to change the default props of this component with the theme.

SliderOutput API

Import

import * as Slider from '@base_ui/react/Slider';
const SliderOutput = Slider.Output;

Props

Props of the native component are also available.

NameTypeDescription
classNamefunc
| string

Class names applied to the element or a function that returns them based on the component's state.

renderelement
| func

A function to customize rendering of the component.


The ref is forwarded to the root element.

Theme default props

You can use SliderOutput to change the default props of this component with the theme.

SliderRoot API

Import

import * as Slider from '@base_ui/react/Slider';
const SliderRoot = Slider.Root;

Props

Props of the native component are also available.

NameTypeDefaultDescription
aria-labelledbystring-

The id of the element containing a label for the slider.

classNamefunc
| string
-

Class names applied to the element or a function that returns them based on the component's state.

defaultValueArray<number>
| number
-

The default value of the slider. Use when the component is not controlled.

direction'ltr'
| 'rtl'
'ltr'

Sets the direction. For right-to-left languages, the lowest value is on the right-hand side.

disabledboolfalse

If true, the component is disabled.

idstring-

The id of the slider element.

largeStepnumber10

The granularity with which the slider can step through values when using Page Up/Page Down or Shift + Arrow Up/Arrow Down.

maxnumber100

The maximum allowed value of the slider. Should not be equal to min.

minnumber0

The minimum allowed value of the slider. Should not be equal to max.

minStepsBetweenValuesnumber0

The minimum steps between values in a range slider.

namestring-

Name attribute of the hidden input element.

onValueChangefunc-

Callback function that is fired when the slider's value changed.

Signature:function(value: number | Array, activeThumb: number, event: Event) => void
  • value The new value.
  • activeThumb Index of the currently moved thumb.
  • event The event source of the callback. You can pull out the new value by accessing event.target.value (any). Warning: This is a generic event not a change event.
onValueCommittedfunc-

Callback function that is fired when the pointerup is triggered.

Signature:function(value: number | Array, event: Event) => void
  • value The new value.
  • event The event source of the callback. Warning: This is a generic event not a change event.
orientation'horizontal'
| 'vertical'
'horizontal'

The component orientation.

renderelement
| func
-

A function to customize rendering of the component.

stepnumber1

The granularity with which the slider can step through values. (A "discrete" slider.) The min prop serves as the origin for the valid values. We recommend (max - min) to be evenly divisible by the step.

tabIndexnumber-

Tab index attribute of the Thumb component's input element.

valueArray<number>
| number
-

The value of the slider. For ranged sliders, provide an array with two values.


The ref is forwarded to the root element.

Theme default props

You can use SliderRoot to change the default props of this component with the theme.

SliderThumb API

Import

import * as Slider from '@base_ui/react/Slider';
const SliderThumb = Slider.Thumb;

Props

Props of the native component are also available.

NameTypeDescription
aria-labelstring

The label for the input element.

aria-valuetextstring

A string value that provides a user-friendly name for the current value of the slider.

classNamefunc
| string

Class names applied to the element or a function that returns them based on the component's state.

getAriaLabelfunc

Accepts a function which returns a string value that provides a user-friendly name for the input associated with the thumb

Signature:function(index: number) => string
  • index The index of the input
getAriaValueTextfunc

Accepts a function which returns a string value that provides a user-friendly name for the current value of the slider. This is important for screen reader users.

Signature:function(value: number, index: number) => string
  • value The thumb label's value to format.
  • index The thumb label's index to format.
renderfunc
| node

A function to customize rendering of the component.


The ref is forwarded to the root element.

Theme default props

You can use SliderThumb to change the default props of this component with the theme.

SliderTrack API

Import

import * as Slider from '@base_ui/react/Slider';
const SliderTrack = Slider.Track;

Props

Props of the native component are also available.

NameTypeDescription
classNamefunc
| string

Class names applied to the element or a function that returns them based on the component's state.

renderelement
| func

A function to customize rendering of the component.


The ref is forwarded to the root element.

Theme default props

You can use SliderTrack to change the default props of this component with the theme.