Slider
Lab componentSlider
Slider
enables the selection of a single value within a range of values. The control is oriented horizontally, and the currently-selected value is displayed in a tooltip.
By default the minimum and maximum values are shown, and can be displayed either inline or below the track (using the marks
prop to "bottom"
).
Alternately, incremental marks can be shown along the track by setting the marks
prop to "all"
. The incremental marks will match the step
prop value (i.e. for a step
value of 5
, the marks will display as "0", "5", "10", "15", etc.) Note that when all marks are shown, they are always displayed below the track.
A tooltip displays the value of a slider "thumb" when the thumb is focused or hovered. The tooltip remains persistent on cursor drag or moving the thumb along the track with keyboard interaction.
If two values are provided (either to the value
or defaultValue
props), then the slider will render as a range slider. Thumbs cannot pass or overlap.
By default, the slider step increment is set to 1. This can be customized by using the ‘step’ prop.
Custom step values can be set to any number, including decimal values up to two decimal places. If a decimal step value is provided, the marks (if shown) will also be displayed as decimal values.
If a custom step value is provided that is not a multiple of the range, the slider will round the maximum selectable value to the largest multiple of the step that is less than the maximum value. Note: This will render the final portion of the slider track unusable (the portion between the rounded maximum value and the actual maximum value). Step calculations are made from 0
, so the same rounding logic applies to negative values, but in the opposite direction.
- Use a step value that is a multiple of the range to ensure the entire range is selectable.
- Use a step value that is relative to the granularity of the scale to prevent tedious slider selections.
To display a label alongside a slider, use FormField and FormFieldLabel. For more information, refer to the form field documentation.
We recommend using labels with slider to provide context and aid the user in understanding the value being selected.
You can display inputs with either a single or range slider. Inputs are used to enter a numeric value from the predefined range, enabling the thumb to jump to the specified value.
"Out of range" changes to the value (i.e. setting the input to a value above or below the slider's min
and max
values) will be rounded to the nearest valid value for the slider. When using a range slider, the upper and lower values cannot overlap (i.e. the lower value cannot be set to a value higher than the upper value). If the input value is set to a value that would cause an overlap, the range value will be set to the nearest valid value.
- For single slider, display one input to the left of the track.
- When using inputs, ensure the slider is in "controlled" mode (by explicitly setting the
value
prop). - Use the slider's
onChange
callback to update the input values when the slider is interacted with. - Validate your input value changes and update the
validationStatus
prop on any inputs accordingly. - When using the slider alongside an input use the default
marks
setting (do not setmarks
to"bottom"
or"all"
).
By default the minimum and maximum values are shown, and can be displayed either inline or below the track (using the marks
prop to "bottom"
).
Alternately, incremental marks can be shown along the track by setting the marks
prop to "all"
. The incremental marks will match the step
prop value (i.e. for a step
value of 5
, the marks will display as "0", "5", "10", "15", etc.) Note that when all marks are shown, they are always displayed below the track.
A tooltip displays the value of a slider "thumb" when the thumb is focused or hovered. The tooltip remains persistent on cursor drag or moving the thumb along the track with keyboard interaction.
If two values are provided (either to the value
or defaultValue
props), then the slider will render as a range slider. Thumbs cannot pass or overlap.
By default, the slider step increment is set to 1. This can be customized by using the ‘step’ prop.
Custom step values can be set to any number, including decimal values up to two decimal places. If a decimal step value is provided, the marks (if shown) will also be displayed as decimal values.
If a custom step value is provided that is not a multiple of the range, the slider will round the maximum selectable value to the largest multiple of the step that is less than the maximum value. Note: This will render the final portion of the slider track unusable (the portion between the rounded maximum value and the actual maximum value). Step calculations are made from 0
, so the same rounding logic applies to negative values, but in the opposite direction.
- Use a step value that is a multiple of the range to ensure the entire range is selectable.
- Use a step value that is relative to the granularity of the scale to prevent tedious slider selections.
To display a label alongside a slider, use FormField and FormFieldLabel. For more information, refer to the form field documentation.
We recommend using labels with slider to provide context and aid the user in understanding the value being selected.
You can display inputs with either a single or range slider. Inputs are used to enter a numeric value from the predefined range, enabling the thumb to jump to the specified value.
"Out of range" changes to the value (i.e. setting the input to a value above or below the slider's min
and max
values) will be rounded to the nearest valid value for the slider. When using a range slider, the upper and lower values cannot overlap (i.e. the lower value cannot be set to a value higher than the upper value). If the input value is set to a value that would cause an overlap, the range value will be set to the nearest valid value.
- For single slider, display one input to the left of the track.
- When using inputs, ensure the slider is in "controlled" mode (by explicitly setting the
value
prop). - Use the slider's
onChange
callback to update the input values when the slider is interacted with. - Validate your input value changes and update the
validationStatus
prop on any inputs accordingly. - When using the slider alongside an input use the default
marks
setting (do not setmarks
to"bottom"
or"all"
).
By default the minimum and maximum values are shown, and can be displayed either inline or below the track (using the marks
prop to "bottom"
).
Alternately, incremental marks can be shown along the track by setting the marks
prop to "all"
. The incremental marks will match the step
prop value (i.e. for a step
value of 5
, the marks will display as "0", "5", "10", "15", etc.) Note that when all marks are shown, they are always displayed below the track.
A tooltip displays the value of a slider "thumb" when the thumb is focused or hovered. The tooltip remains persistent on cursor drag or moving the thumb along the track with keyboard interaction.
If two values are provided (either to the value
or defaultValue
props), then the slider will render as a range slider. Thumbs cannot pass or overlap.
By default, the slider step increment is set to 1. This can be customized by using the ‘step’ prop.
Custom step values can be set to any number, including decimal values up to two decimal places. If a decimal step value is provided, the marks (if shown) will also be displayed as decimal values.
If a custom step value is provided that is not a multiple of the range, the slider will round the maximum selectable value to the largest multiple of the step that is less than the maximum value. Note: This will render the final portion of the slider track unusable (the portion between the rounded maximum value and the actual maximum value). Step calculations are made from 0
, so the same rounding logic applies to negative values, but in the opposite direction.
- Use a step value that is a multiple of the range to ensure the entire range is selectable.
- Use a step value that is relative to the granularity of the scale to prevent tedious slider selections.
To display a label alongside a slider, use FormField and FormFieldLabel. For more information, refer to the form field documentation.
We recommend using labels with slider to provide context and aid the user in understanding the value being selected.
You can display inputs with either a single or range slider. Inputs are used to enter a numeric value from the predefined range, enabling the thumb to jump to the specified value.
"Out of range" changes to the value (i.e. setting the input to a value above or below the slider's min
and max
values) will be rounded to the nearest valid value for the slider. When using a range slider, the upper and lower values cannot overlap (i.e. the lower value cannot be set to a value higher than the upper value). If the input value is set to a value that would cause an overlap, the range value will be set to the nearest valid value.
- For single slider, display one input to the left of the track.
- When using inputs, ensure the slider is in "controlled" mode (by explicitly setting the
value
prop). - Use the slider's
onChange
callback to update the input values when the slider is interacted with. - Validate your input value changes and update the
validationStatus
prop on any inputs accordingly. - When using the slider alongside an input use the default
marks
setting (do not setmarks
to"bottom"
or"all"
).