Slider
An easily stylable range input.
API reference
Import the component and place its parts the following way:
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.
Prop | Type | Default | |
---|---|---|---|
aria-labelledby | string | undefined | |
className | string | (state) => string | undefined | |
defaultValue | Array<number> | number | undefined | |
disabled | boolean | false | |
format | Intl.NumberFormatOptions | undefined | |
largeStep | number | 10 | |
max | number | 100 | |
min | number | 0 | |
minStepsBetweenValues | number | 0 | |
name | string | undefined | |
onValueChange | (value, event, activeThumbIndex) => void | undefined | |
onValueCommitted | (value, event) => void | undefined | |
orientation | 'horizontal' | 'vertical' | 'horizontal' | |
render | | React.ReactElement | undefined | |
step | number | 1 | |
value | Array<number> | number | undefined |
Attribute | Description | |
---|---|---|
data-dirty | Present when the slider's value has changed (when wrapped in Field.Root). | |
data-disabled | Present when the slider is disabled. | |
data-dragging | Present while the user is dragging. | |
data-invalid | Present when the slider is in invalid state (when wrapped in Field.Root). | |
data-orientation | Indicates the orientation of the slider. | |
data-readonly | Present when the slider is readonly. | |
data-required | Present when the slider is required. | |
data-touched | Present when the slider has been thouched (when wrapped in Field.Root). | |
data-valid | Present when the slider is in valid state (when wrapped in Field.Root).. |
Value
Displays the current value of the slider as text.
Renders an <output>
element.
Prop | Type | Default | |
---|---|---|---|
children | | React.ReactNode | undefined | |
className | string | (state) => string | undefined | |
render | | React.ReactElement | undefined |
Attribute | Description | |
---|---|---|
data-dirty | Present when the slider's value has changed (when wrapped in Field.Root). | |
data-disabled | Present when the slider is disabled. | |
data-dragging | Present while the user is dragging. | |
data-invalid | Present when the slider is in invalid state (when wrapped in Field.Root). | |
data-orientation | Indicates the orientation of the slider. | |
data-readonly | Present when the slider is readonly. | |
data-required | Present when the slider is required. | |
data-touched | Present when the slider has been thouched (when wrapped in Field.Root). | |
data-valid | Present when the slider is in valid state (when wrapped in Field.Root).. |
Control
The clickable, interactive part of the slider.
Renders a <div>
element.
Prop | Type | Default | |
---|---|---|---|
className | string | (state) => string | undefined | |
render | | React.ReactElement | undefined |
Attribute | Description | |
---|---|---|
data-dirty | Present when the slider's value has changed (when wrapped in Field.Root). | |
data-disabled | Present when the slider is disabled. | |
data-dragging | Present while the user is dragging. | |
data-invalid | Present when the slider is in invalid state (when wrapped in Field.Root). | |
data-orientation | Indicates the orientation of the slider. | |
data-readonly | Present when the slider is readonly. | |
data-required | Present when the slider is required. | |
data-touched | Present when the slider has been thouched (when wrapped in Field.Root). | |
data-valid | Present when the slider is in valid state (when wrapped in Field.Root).. |
Track
Contains the slider indicator and represents the entire range of the slider.
Renders a <div>
element.
Prop | Type | Default | |
---|---|---|---|
className | string | (state) => string | undefined | |
render | | React.ReactElement | undefined |
Attribute | Description | |
---|---|---|
data-dirty | Present when the slider's value has changed (when wrapped in Field.Root). | |
data-disabled | Present when the slider is disabled. | |
data-dragging | Present while the user is dragging. | |
data-invalid | Present when the slider is in invalid state (when wrapped in Field.Root). | |
data-orientation | Indicates the orientation of the slider. | |
data-readonly | Present when the slider is readonly. | |
data-required | Present when the slider is required. | |
data-touched | Present when the slider has been thouched (when wrapped in Field.Root). | |
data-valid | Present when the slider is in valid state (when wrapped in Field.Root).. |
Indicator
Visualizes the current value of the slider.
Renders a <div>
element.
Prop | Type | Default | |
---|---|---|---|
className | string | (state) => string | undefined | |
render | | React.ReactElement | undefined |
Attribute | Description | |
---|---|---|
data-dirty | Present when the slider's value has changed (when wrapped in Field.Root). | |
data-disabled | Present when the slider is disabled. | |
data-dragging | Present while the user is dragging. | |
data-invalid | Present when the slider is in invalid state (when wrapped in Field.Root). | |
data-orientation | Indicates the orientation of the slider. | |
data-readonly | Present when the slider is readonly. | |
data-required | Present when the slider is required. | |
data-touched | Present when the slider has been thouched (when wrapped in Field.Root). | |
data-valid | Present when the slider is in valid state (when wrapped in Field.Root).. |
Thumb
The draggable part of the the slider at the tip of the indicator.
Renders a <div>
element.
Prop | Type | Default | |
---|---|---|---|
aria-label | string | undefined | |
aria-valuetext | string | undefined | |
className | string | (state) => string | undefined | |
getAriaLabel | function(index: number) => string | undefined | |
getAriaValueText | function(formattedValue: string, value: number, index: number) => string | undefined | |
render | | React.ReactElement | undefined |
Attribute | Description | |
---|---|---|
data-dirty | Present when the slider's value has changed (when wrapped in Field.Root). | |
data-disabled | Present when the slider is disabled. | |
data-dragging | Present while the user is dragging. | |
data-invalid | Present when the slider is in invalid state (when wrapped in Field.Root). | |
data-orientation | Indicates the orientation of the slider. | |
data-readonly | Present when the slider is readonly. | |
data-required | Present when the slider is required. | |
data-touched | Present when the slider has been thouched (when wrapped in Field.Root). | |
data-valid | Present when the slider is in valid state (when wrapped in Field.Root).. |