Skip to main content

rc-slider

Single-thumb slider backed by a native <input type="range"> with custom track and value display hooks, following the WAI-ARIA Slider pattern.

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

Installation​

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

Usage​

Wrap a native <input type="range">. It stays in the page as the form value, the keyboard control, and the no-JavaScript fallback. Label it as any range input.

<label for="volume">Volume</label>
<rc-slider>
<input id="volume" name="volume" type="range" min="0" max="100" value="40" />
</rc-slider>

Live demo​

Accessibility​

The native range input keeps its slider role and keyboard behavior. The component forwards value-text to aria-valuetext, orientation="vertical" to aria-orientation, and readonly to aria-readonly, and its track and value display are decorative.

KeyAction
Arrow keysNative: moves the value one step.
Home, EndNative: moves to the minimum or maximum.
Page Up, Page DownMoves the value ten steps up or down.

A readonly slider ignores Page Up and Page Down and restores its value after any other key or pointer change. See the WAI-ARIA 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.

API​

Properties​

PropertyMarkupTypeDefaultDescription
minminnumber0Minimum slider value.
maxmaxnumber100Maximum slider value.
stepstepnumber1Slider step.
valuevaluenumberNot specifiedCurrent slider value.
defaultValuedefault-valuenumber | undefinedNot specifiedInitial uncontrolled slider value. Has no effect after the first user interaction or `value` write.
disableddisabledbooleanfalseDisable the underlying input.
readonlyreadonlybooleanfalsePrevents edits while preserving normal display. Not a native range attribute.
displaydisplayDisplayValuenullControls the live value display. - Absent (default) — no value shown. - `display` or `display="float"` — floats above the thumb. - `display="inline-start"` — rendered before the track, inline in the grid. - `display="inline-end"` — rendered after the track, inline in the grid.
valueTextvalue-textstring''Screen-reader value text. When set, forwarded as `aria-valuetext` on the native input.
orientationorientation'horizontal' | 'vertical''horizontal'Orientation; reflected as an attribute and forwarded to `aria-orientation`.

Events​

EventDetail typeDescription
rc-slider-inputCustomEventFires continuously while the value changes. Detail: `{ value }`.
rc-slider-changeCustomEventFires when the committed value changes (on release). Detail: `{ value }`.

Slots​

NameDescription
track-backgroundOptional decorative content rendered inside the track before the progress fill.
value-displayOptional replacement for the rendered value text.

CSS Custom Properties​

PropertyDefaultDescription
--rc-thumb-radius9pxHalf the thumb width; used to position the float value display.
--rc-slider-gapvar(--rc-control-gap)Gap between track and inline value display.
--rc-slider-control-sizevar(--rc-control-block-size)Track hit-area block size.
--rc-slider-vertical-size12.5remTrack length when `orientation="vertical"`.
--rc-slider-track-size0.1875remVisual track thickness.
--rc-slider-track-backgroundCanvasTextUnfilled track color.
--rc-slider-track-opacity0.25Unfilled track opacity.
--rc-slider-track-radiusvar(--rc-control-radius)Track border radius.
--rc-slider-progress-backgroundvar(--rc-accent)Filled track color.
--rc-slider-value-colorvar(--rc-text-disabled)Value display text color.
--rc-slider-float-value-block-offset-1.4emBlock-axis offset for horizontal float value display.
--rc-slider-float-value-inline-offsetcalc(100% + 0.5rem)Inline-axis offset for vertical float value display.

CSS Parts​

PartDescription
rootRoot layout wrapper.
controlTrack/input positioning wrapper.
trackVisual slider track.
progressFilled progress segment.
value-displayRendered value text.