Dojo's RangeSlider widget creates a range slider control with a styleable track, fill, and draggable thumb controls.
- Horizontal slider with a track, fill, and two thumbs
- Output node with customizable text that can be used to display the current minimum/maximum values.
RangeSlider uses two native <input type="range"> elements as its base, which ensures built-in keyboard and screen reader accessibility. All common form field attributes (disabled, invalid, readOnly, required) may be set, as well as a visible or hidden label. The output node used to display the current value uses <output> and is associated with the inputs.
If the label property is not used, we recommend creating a separate label and pointing it at the input's widgetId property.
Separate minimumLabel and maximumLabel properties are provided to customize the aria labels of each range element.
// Basic horizontal slider
w(RangeSlider, {
label: 'Choose a number range from 1 to 100',
min: 0,
max: 100,
step: 1,
minValue: this.state.min,
maxValue: this.state.max,
onInput: (min: number, max: number) => {
this.setState({ min, max });
},
});The following CSS classes are available on the RangeSlider widget for use with custom themes:
root: Applied to either the wrapping<label>, or a<div>in the same position in the node hierarchyinputWrapper: Applied to the immediate parent of the<input>and custom track. This element is used to render the custom track.input: Applied to the native<input>elementsfill: Applied to the element used for the custom fill, a child of the trackthumb: Applied to the element used as a custom thumb, a child of theinputWrapperthumbLeft: Applied to the element representing the minimum custom thumb, a child of theinputWrapperthumbRight: Applied to the element representing the maximum custom thumb, a child of theinputWrapperoutput: Applied to the<output>element used to display the current valueleftThumb: Applied to the thumb representing the minimum valuerightThumb: Applied to the thumb representing the maximum value
Conditional Classes
disabled: Applied to the same level asrootifproperties.disabledis truereadonly: Applied to the same level asrootifproperties.readOnlyis truerequired: Applied to the same level asrootifproperties.requiredis trueinvalid: Applied to the same level asrootifproperties.invalidis truefocus: Applied to a custom thumb when it has focusoutputIsTooltip: Applied to the<output>element if theoutputIsTooltipproperty is true.