Skip to content

SliderUnstyled API

The API documentation of the SliderUnstyled React component. Learn more about the props and the CSS customization points.

Import

import SliderUnstyled from '@material-ui/lab/SliderUnstyled';
// or
import { SliderUnstyled } from '@material-ui/lab';

You can learn more about the difference by reading this guide.

Props

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.
classes object Override or extend the styles applied to the component.
color 'primary'
| 'secondary'
'primary' The color of the component. It supports those theme colors that make sense for this component.
component elementType 'span' The component used for the root node. Either a string to use a HTML element or a component.
defaultValue Array<number>
| number
The default element value. Use when the component is not controlled.
disabled bool false If true, the slider will be disabled.
getAriaLabel func Accepts a function which returns a string value that provides a user-friendly name for the thumb labels of the slider.

Signature:
function(index: number) => string
index: The thumb label's index to format.
getAriaValueText func Accepts a function which returns a string value that provides a user-friendly name for the current value of the slider.

Signature:
function(value: number, index: number) => string
value: The thumb label's value to format.
index: The thumb label's index to format.
isRtl bool false Indicates whether the theme context has rtl direction. It is set automatically.
marks Array<{ label?: node, value: number }>
| bool
false Marks indicate predetermined values to which the user can move the slider. If true the marks will be spaced according the value of the step prop. If an array, it should contain objects with value and an optional label keys.
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 input element.
onChange func Callback function that is fired when the slider's value changed.

Signature:
function(event: object, value: number | number[]) => void
event: The event source of the callback. Warning: This is a generic event not a change event.
value: The new value.
onChangeCommitted func Callback function that is fired when the mouseup is triggered.

Signature:
function(event: object, value: number | number[]) => void
event: The event source of the callback. Warning: This is a generic event not a change event.
value: The new value.
orientation 'horizontal'
| 'vertical'
'horizontal' The slider orientation.
scale func (x) => x A transformation function, to change the scale of the slider.
step number 1 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.
When step is null, the thumb can only be slid onto marks provided with the marks prop.
ThumbComponent elementType The component used to display the value label.
track 'inverted'
| 'normal'
| false
'normal' The track presentation:
- normal the track will render a bar representing the slider value. - inverted the track will render a bar representing the remaining slider value. - false the track will render without a bar.
value Array<number>
| number
The value of the slider. For ranged sliders, provide an array with two values.
valueLabelDisplay 'auto'
| 'off'
| 'on'
'off' Controls when the value label is displayed:
- auto the value label will display when the thumb is hovered or focused. - on will display persistently. - off will never display.
valueLabelFormat func
| string
(x) => x The format function the value label's value.
When a function is provided, it should have the following signature:
- {number} value The value label's value to format - {number} index The value label's index to format

The ref is forwarded to the root element.

Any other props supplied will be provided to the root element (native element).