A Range input lets users pick a numeric value along a track using a handle.
Usage
"unfilled"
The unfilled option makes the Range not be filled in to the left of the thumb.
The preview has been updated.
Skins
Different skins are available for the common use cases of hue
, contrast
, and saturation
, respectively. These skins are always "unfilled" to the left of the thumb.
The preview has been updated.
Note that the saturation
skin requires a value of gradientEndColor
for the fully-saturated color shown at the Range's right end.
Custom
The custom
skin allows you to create a Range with a smooth gradient between two custom colors, which are specified using gradientStartColor
and gradientEndColor
. This skin is always "unfilled" to the left of the thumb.
The preview has been updated.
Managing State in React
As is the case with most form elements, folks often want to "control" this component. Controlling a component means that you take ownership over its state rather than letting the browser manage the state for you. When you control component, you own the source of truth for the UI. This means that you don't need to query the DOM in order to determine the current value of the element. So, when it comes time to use the value of the element somewhere else (e.g. submitting the selection to a back-end service), you can trust your stored value.
If you'd like to control this component, you'll need store the currently-selected value somewhere (e.g. React state or a Redux store), and you'll need to provide a handler to update that value when the user interacts with the component.
e.g.