Unstyled Slider
A slider is a UI element that lets users select a single value or a range of values along a bar.
useSlider API
Import
import useSlider from '@mui/base/useSlider';
// or
import { useSlider } from '@mui/base';Parameters
| Name | Type | Default | Description | 
|---|---|---|---|
| ref* | React.Ref<any> | The ref attached to the root of the Slider. | |
| aria-labelledby | string | The id of the element containing a label for the slider. | |
| defaultValue | number | number[] | The default value. Use when the component is not controlled. | |
| disabled | boolean | false | If  true, the component is disabled. | 
| disableSwap | boolean | false | If  true, the active thumb doesn't swap when moving pointer over a thumb while dragging another thumb. | 
| isRtl | boolean | false | If  truethe Slider will be rendered right-to-left (with the lowest value on the right-hand side). | 
| marks | boolean | Mark[] | false | Marks indicate predetermined values to which the user can move the slider.
If  truethe marks are spaced according the value of thestepprop.
If an array, it should contain objects withvalueand an optionallabelkeys. | 
| 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  inputelement. | |
| onChange | (event: Event, value: number | number[], activeThumb: number) => void | Callback function that is fired when the slider's value changed. | |
| onChangeCommitted | (event: React.SyntheticEvent | Event, value: number | number[]) => void | Callback function that is fired when the  mouseupis triggered. | |
| orientation | 'horizontal' | 'vertical' | 'horizontal' | The component orientation. | 
| scale | (value: number) => number | function Identity(x) { return x; } | A transformation function, to change the scale of the slider. | 
| step | number | null | 1 | The granularity with which the slider can step through values. (A "discrete" slider.)
The  minprop serves as the origin for the valid values.
We recommend (max - min) to be evenly divisible by the step.
When step isnull, the thumb can only be slid onto marks provided with themarksprop. | 
| tabIndex | number | Tab index attribute of the hidden  inputelement. | |
| value | number | number[] | The value of the slider.
For ranged sliders, provide an array with two values. | 
Return value
| Name | Type | Default | Description | 
|---|---|---|---|
| active | number | -1 | The active index of the slider. | 
| axis | Axis | horizontal | The orientation of the slider. | 
| axisProps | { [key in Axis]: AxisProps<key> } | Returns the  offsetandleapmethods to calculate the positioning styles based on the slider axis. | |
| dragging | boolean | false | If  true, the slider is being dragged. | 
| focusedThumbIndex | number | The index of the thumb which is focused on the slider. | |
| getHiddenInputProps | <TOther extends EventHandlers = {}>(otherHandlers?: TOther) => UseSliderHiddenInputProps<TOther> | Resolver for the hidden input slot's props. | |
| getRootProps | <TOther extends EventHandlers = {}>(otherHandlers?: TOther) => UseSliderRootSlotProps<TOther> | Resolver for the root slot's props. | |
| getThumbProps | <TOther extends EventHandlers = {}>(otherHandlers?: TOther) => UseSliderThumbSlotProps<TOther> | Resolver for the thumb slot's props. | |
| marks | Mark[] | The marks of the slider. Marks indicate predetermined values to which the user can move the slider. | |
| open | number | -1 | The thumb index for the current value when in hover state. | 
| range | boolean | If  true, the slider is a range slider when thevalueprop passed is an array. | |
| trackLeap | number | The track leap for the current value of the slider. | |
| trackOffset | number | The track offset for the current value of the slider. | |
| values | number[] | The possible values of the slider. |