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 of the native component are also available.
Name | Type | Description |
---|---|---|
className | func | string | Class names applied to the element or a function that returns them based on the component's state. |
render | element | func | A function to customize rendering of the component. |
ref
is forwarded to the root element.Theme default props
You can useSliderControl
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 of the native component are also available.
Name | Type | Description |
---|---|---|
className | func | string | Class names applied to the element or a function that returns them based on the component's state. |
render | element | func | A function to customize rendering of the component. |
ref
is forwarded to the root element.Theme default props
You can useSliderIndicator
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 of the native component are also available.
Name | Type | Description |
---|---|---|
className | func | string | Class names applied to the element or a function that returns them based on the component's state. |
render | element | func | A function to customize rendering of the component. |
ref
is forwarded to the root element.Theme default props
You can useSliderOutput
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 of the native component are also available.
Name | Type | Default | Description |
---|---|---|---|
aria-labelledby | string | - | The id of the element containing a label for the slider. |
className | func | string | - | Class names applied to the element or a function that returns them based on the component's state. |
defaultValue | Array<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. |
disabled | bool | false | If |
id | string | - | The id of the slider element. |
largeStep | number | 10 | The granularity with which the slider can step through values when using Page Up/Page Down or Shift + Arrow Up/Arrow Down. |
max | number | 100 | The maximum allowed value of the slider. Should not be equal to min. |
min | number | 0 | The minimum allowed value of the slider. Should not be equal to max. |
minStepsBetweenValues | number | 0 | The minimum steps between values in a range slider. |
name | string | - | Name attribute of the hidden |
onValueChange | func | - | Callback function that is fired when the slider's value changed. Signature: function(value: number | Array
|
onValueCommitted | func | - | Callback function that is fired when the Signature: function(value: number | Array
|
orientation | 'horizontal' | 'vertical' | 'horizontal' | The component orientation. |
render | element | func | - | A function to customize rendering of the component. |
step | number | 1 | The granularity with which the slider can step through values. (A "discrete" slider.) The |
tabIndex | number | - | Tab index attribute of the Thumb component's |
value | Array<number> | number | - | The value of the slider. For ranged sliders, provide an array with two values. |
ref
is forwarded to the root element.Theme default props
You can useSliderRoot
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 of the native component are also available.
Name | Type | Description |
---|---|---|
aria-label | string | The label for the input element. |
aria-valuetext | string | A string value that provides a user-friendly name for the current value of the slider. |
className | func | string | Class names applied to the element or a function that returns them based on the component's state. |
getAriaLabel | func | 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
|
getAriaValueText | func | 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
|
render | func | node | A function to customize rendering of the component. |
ref
is forwarded to the root element.Theme default props
You can useSliderThumb
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 of the native component are also available.
Name | Type | Description |
---|---|---|
className | func | string | Class names applied to the element or a function that returns them based on the component's state. |
render | element | func | A function to customize rendering of the component. |
ref
is forwarded to the root element.Theme default props
You can useSliderTrack
to change the default props of this component with the theme.