Slider
Capture user feedback from a range of values
Import
Source
Docs
Package
Usage
20%
50%
80%
Type
Color
Size
xs
sm
md
lg
xl
Radius
xs
sm
md
lg
xl
Controlled
By default, both Slider and RangeSlider are uncontrolled, add onChange and value props to make them controlled:
Disabled
xs
sm
md
lg
xl
onChangeEnd
onChangeEnd
callback is called when user stops dragging the slider or uses arrows:
onChange value: 50
onChangeEnd value: 50
Control label
To change label behavior and appearance, set the following props:
label
– formatter function, accepts value as an argument, set null to disable label, defaults tof => f
labelAlwaysOn
– if true – label will always be displayed, by default label is visible only when user is dragginglabelTransition
,labelTransitionDuration
,labelTransitionTimingFunction
– label uses Transition component to animate presence, you can choose any premade transition or create your own
No label
Formatted label
Label always visible
40
Custom label transition
Min, max and step
Decimal step
Step matched with marks
xs
sm
md
lg
xl
Marks
Add any number of marks to slider by setting marks
prop to an array of objects:
Note that mark value is relative to slider value, not width:
20%
50%
80%
20%
50%
80%
Styles API
You can change styles of any element in slider component with Styles API to match your design requirements:
20%
50%
80%
Accessibility and usability
Slider and RangeSlider components are accessible by default:
- Slider thumbs are focusable
- When the user uses mouse to interact with a slider, focus is moved on slider track, when the user presses arrows focus is moved on thumb
- Value can be changed with arrows with step increment/decrement
To label component for screen readers, add labels to thumbs: