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-slider
import '@rcarls/rc-slider/define';

Live demo

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`.

Methods

No public methods are documented in the custom elements manifest.

Events

EventDetail typeDescription
typeCustomEventNo description provided.
rc-slider-inputNo detail type documentedFires continuously while the value changes. Detail: `{ value }`.
rc-slider-changeNo detail type documentedFires 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-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.