Skip to main content

rc-range-slider

Two-thumb range slider backed by native range inputs for min/max values, following the WAI-ARIA Multi-Thumb Slider pattern.

Package
@rcarls/rc-range-slider
Element
<rc-range-slider>
Native dependency
Requires two native range input children
State model
Controlled or uncontrolled numeric tuple
Main events
rc-range-slider-inputrc-range-slider-change

Installation​

npm install @rcarls/rc-webcomponents@next
import '@rcarls/rc-webcomponents/rc-range-slider/define';

Usage​

Wrap two native range inputs, the low value first. They stay in the page as the form values and the no-JavaScript fallback. Name the group and each input.

<rc-range-slider aria-label="Price range">
<input type="range" name="price-min" min="0" max="100" value="20" aria-label="Minimum" />
<input type="range" name="price-max" min="0" max="100" value="80" aria-label="Maximum" />
</rc-range-slider>

Live demo​

Accessibility​

After upgrade, two thumbs with role="slider" in a group replace the native inputs for keyboard and assistive technology, while the hidden inputs keep their name and value for form submission. Each thumb's aria-valuemin and aria-valuemax follow the other thumb, so the low value cannot pass the high value. low-value-text and high-value-text set aria-valuetext.

KeyAction
Right Arrow, Up ArrowRaises the focused thumb one step.
Left Arrow, Down ArrowLowers the focused thumb one step.
Page Up, Page DownRaises or lowers the focused thumb ten steps.
Home, EndMoves the focused thumb to its lowest or highest position.

Along the rendered track, the arrow that points toward higher values raises the thumb, so Left and Right swap in right-to-left text. A readonly or disabled slider ignores these keys. See the WAI-ARIA multi-thumb slider pattern.

Theming​

The default demo mode shows the component without a package theme. Use the shared preview controls on this page to compare inherited, light, and dark color schemes or to apply the optional Material theme only inside the demo frames.

Localization​

Built-in text follows the element's own lang, else <html lang>. Override it with messages, or register it for every instance under rc-range-slider: low, high. See Localization.

API​

Properties​

PropertyMarkupTypeDefaultDescription
minminnumber0Minimum slider value.
maxmaxnumber100Maximum slider value.
stepstepnumber1Slider step.
valueJS property only[number, number]Not specifiedCurrent [low, high] value. Assign a new tuple reference to trigger a re-render.
defaultValueJS property only[number, number] | undefinedNot specifiedInitial uncontrolled [low, high] value. Has no effect after the first user interaction or `value` write.
disableddisabledbooleanfalseDisable both thumbs and their hidden native input reflectors.
readonlyreadonlybooleanfalsePrevents edits while preserving normal focus and display.
messagesJS property onlyPartial<RCRangeSliderMessages> | undefinedNot specifiedBuilt-in text overrides; unset keys fall back to registered text, then English.
lowLabellow-labelstring | undefinedNot specifiedAccessible label for the low (min) thumb when the input does not provide one. Defaults to the `low` message.
highLabelhigh-labelstring | undefinedNot specifiedAccessible label for the high (max) thumb when the input does not provide one. Defaults to the `high` message.
lowValueTextlow-value-textstring''Formatted screen-reader text for the low value. Falls back to the raw number.
highValueTexthigh-value-textstring''Formatted screen-reader text for the high value. Falls back to the raw number.
displaydisplayDisplayValuenullControls the live value display. - Absent (default) — no value shown. - `display` or `display="float"` — floats each value above its thumb. - `display="inline-start"` — renders the value container before the track. - `display="inline-end"` — renders the value container after the track.
orientationorientation'horizontal' | 'vertical''horizontal'Orientation; reflected as an attribute and forwarded to custom thumbs.

Events​

EventDetail typeDescription
rc-range-slider-inputCustomEventFires while either thumb moves. Detail: `{ value }`.
rc-range-slider-changeCustomEventFires when a thumb commits a new value. Detail: `{ value }`.

Slots​

NameDescription
(default)Consumer-provided native range inputs.
track-backgroundOptional decorative content rendered inside the track before the selected range fill.
low-value-displayOptional replacement for the low value text.
high-value-displayOptional replacement for the high value text.

CSS Custom Properties​

PropertyDefaultDescription
--rc-range-slider-accentHighlightAccent color for selected range, thumb border, focus, hover, and active states.
--rc-range-slider-gapvar(--rc-control-gap)Gap between track and inline value display.
--rc-range-slider-control-sizevar(--rc-control-block-size)Track hit-area block size.
--rc-range-slider-vertical-size12.5remTrack length when `orientation="vertical"`.
--rc-range-slider-track-size0.1875remVisual track thickness.
--rc-range-slider-track-backgroundcolor-mix(in srgb, CanvasText 25%, Canvas)Unselected track color.
--rc-range-slider-track-radiusvar(--rc-control-radius)Track border radius.
--rc-range-slider-range-backgroundNot specifiedFilled selected-range color. Defaults to `--rc-range-slider-accent` (`GrayText` when `disabled`).
--rc-range-slider-thumb-backgroundButtonFaceThumb background color.
--rc-range-slider-thumb-bordervar(--rc-range-slider-accent)Thumb border color.
--rc-range-slider-thumb-size1.125remVisual thumb inline/block size.
--rc-range-slider-thumb-hover-backgroundNot specifiedThumb background on hover. Defaults to `--rc-range-slider-accent` (`ButtonFace` when `disabled`).
--rc-range-slider-thumb-hover-borderNot specifiedThumb border color on hover. Defaults to `--rc-range-slider-accent` (`GrayText` when `disabled`).
--rc-range-slider-thumb-active-backgroundNot specifiedThumb background while pressed. Defaults to `--rc-range-slider-accent` (`ButtonFace` when `disabled`).
--rc-range-slider-thumb-active-borderNot specifiedThumb border color while pressed. Defaults to `--rc-range-slider-accent` (`GrayText` when `disabled`).
--rc-range-slider-focus-outlineNot specifiedThumb focus ring color. Defaults to `--rc-range-slider-accent` (`GrayText` when `disabled`).
--rc-range-slider-value-colorvar(--rc-text-disabled)Value display text color.
--rc-thumb-radius9pxHalf the thumb width; used to align float value displays and range fill.
--rc-range-slider-float-value-block-offset-1.4emBlock-axis offset for horizontal float value displays.
--rc-range-slider-float-value-inline-offsetcalc(100% + 0.5rem)Inline-axis offset for vertical float value displays.

CSS Parts​

PartDescription
rootRoot layout wrapper.
groupSlider group wrapper.
trackVisual slider track.
rangeFilled selected range segment.
thumbShared custom slider thumb.
low-thumbLow-value custom slider thumb.
high-thumbHigh-value custom slider thumb.
value-displayShared rendered value text.
low-value-displayRendered low value text.
high-value-displayRendered high value text.