Slider
A slider is a UI element that lets users select a single value or a range of values along a bar.
Slider API
Import
import { Slider } from '@mui/base/Slider';
// or
import { Slider } from '@mui/base';Props of the native component are also available.
| Name | Type | Default | Description |
|---|---|---|---|
| aria-label | string | - | The label of the slider. |
| aria-labelledby | string | - | The id of the element containing a label for the slider. |
| aria-valuetext | string | - | A string value that provides a user-friendly name for the current value of the slider. |
| defaultValue | Array<number> | number | - | The default value. Use when the component is not controlled. |
| disabled | bool | false | If |
| disableSwap | bool | false | If |
| getAriaLabel | func | - | Accepts a function which returns a string value that provides a user-friendly name for the thumb labels of the slider. This is important for screen reader users. 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
|
| isRtl | bool | false | If |
| marks | Array<{ label?: node, value: number }> | bool | false | Marks indicate predetermined values to which the user can move the slider. If |
| 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. |
| name | string | - | Name attribute of the hidden |
| onChange | func | - | Callback function that is fired when the slider's value changed. Signature: function(event: Event, value: number | Array
|
| onChangeCommitted | func | - | Callback function that is fired when the Signature: function(event: React.SyntheticEvent | Event, value: number | Array
|
| orientation | 'horizontal' | 'vertical' | 'horizontal' | The component orientation. |
| scale | func | function Identity(x) { return x; } | A transformation function, to change the scale of the slider. Signature: function(x: any) => any |
| shiftStep | number | 10 | The granularity with which the slider can step through values when using Page Up/Page Down or Shift + Arrow Up/Arrow Down. |
| slotProps | { input?: func | object, mark?: func | object, markLabel?: func | object, rail?: func | object, root?: func | object, thumb?: func | object, track?: func | object, valueLabel?: any | func } | {} | The props used for each slot inside the Slider. |
| slots | { input?: elementType, mark?: elementType, markLabel?: elementType, rail?: elementType, root?: elementType, thumb?: elementType, track?: elementType, valueLabel?: elementType } | {} | The components used for each slot inside the Slider. Either a string to use a HTML element or a component. See Slots API below for more details. |
| step | number | 1 | The granularity with which the slider can step through values. (A "discrete" slider.) The |
| tabIndex | number | - | Tab index attribute of the hidden |
| track | 'inverted' | 'normal' | false | 'normal' | The track presentation:
|
| value | Array<number> | number | - | The value of the slider. For ranged sliders, provide an array with two values. |
| valueLabelFormat | func | string | function Identity(x) { return x; } | The format function the value label's value. |
ref is forwarded to the root element.