Usage
Controlled
Disabled
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 => flabelAlwaysOn– if true – label will always be displayed, by default label is visible only when user is dragginglabelTransitionProps– props passed down to the Transition component, can be used to customize label animation
No label
Formatted label
Label always visible
Custom label transition
Min, max and step
Decimal step
Step matched with marks
Domain
By default, min and max values define the possible range of values.
domain prop allows setting the possible range of values independently of the
min and max values:
Decimal values
To use RangeSlider with decimal values, set min, max and step props:
minRange
Use minRange prop to control minimum range between from and to values
in RangeSlider. The default value is 10. The example below shows how to
use minRange prop to capture decimal values from the user:
pushOnOverlap
pushOnOverlap prop controls whether the thumbs should push each other when they overlap.
By default, pushOnOverlap is true, if you want to disable this behavior, set it to false.
Example of pushOnOverlap={false}:
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:
Restrict selection to marks
Set restrictToMarks prop to restrict slider value to marks only. Note that in
this case step prop is ignored:
Inverted
You can invert the track with the inverted prop:
Accessibility
RangeSlider component is accessible by default:
- Thumbs are focusable
- When the user uses mouse to interact with the slider, focus is moved to the slider track, when the user presses arrows focus is moved to the thumb
- Value can be changed with arrows with step increment/decrement
To label component for screen readers, add labels to thumbs: