0.1.0-rc.2

Slider

Sliders let users pick a numeric value or range along a track. They work well when the approximate value matters more than precise typing.

Try it

Usage

Set min, max, and step to define the range. Use variant="range" with rangeMin and rangeMax for dual-thumb selection.

import { RuiSlider } from '@ecopages/radiant-ui/slider';
import { RuiField } from '@ecopages/radiant-ui/field';
import { RuiLabel } from '@ecopages/radiant-ui/label';
 
<RuiField name="volume">
  <RuiLabel>Volume</RuiLabel>
  <RuiSlider variant="single" value={50} min={0} max={100} step={1} />
</RuiField>

Range selection

Use variant="range" for minimum/maximum filters. Set minDistance to prevent the thumbs from overlapping.

Step size

Match step to meaningful increments, such as whole percentages, not arbitrary fractions.

Theming

Slider surfaces map to semantic surface roles, never Tailwind palette steps:

PartCSS roles
Track (.rui-slider__range-track)surface
Fill (.rui-slider__range-fill)primary
Thumb (.rui-slider__thumb)background surface, primary border, shadow-sm
Native input (.rui-slider__input)primary accent
Value readout (.rui-slider__value)on-surface
Focus ringfocus-ring

Range thumb positions come from --rui-slider-min / --rui-slider-max, set inline by the element from the live range, not theme tokens. Override at the theme layer, not in component CSS.

API

RuiSlider is a custom element (<rui-slider>); the view is a thin passthrough that maps values to rangeMin / rangeMax.

Attributes

AttributeTypeDefaultDescription
variantsingle · rangesingleSingle-thumb or dual-thumb range.
valuenumber50Selected value (single mode).
range-minnumber25Lower thumb value (range mode).
range-maxnumber75Upper thumb value (range mode).
minnumber0Range minimum.
maxnumber100Range maximum.
stepnumber1Arrow-key and pointer snap interval.
min-distancenumber0Minimum gap enforced between range thumbs.
disabledbooleanfalseDisables interaction.
labelstring''Accessible name for the slider.
namestring''Form field name (single mode native input).

Events

EventDetailDescription
rui-change{ value: number } or { values: [number, number] }Emitted as the value moves; value in single mode, values in range mode.

CSS classes

Public BEM classes (documented via @cssclass on the element):

ClassDescription
.rui-sliderRoot; wraps the label, track, and value readout.
.rui-slider--rangeRange-mode surface.
.rui-slider__labelOptional visible label.
.rui-slider__inputNative range input (single mode).
.rui-slider__valueLive numeric readout.
.rui-slider__rangeRange-mode track wrapper.
.rui-slider__range-trackTrack surface behind both thumbs.
.rui-slider__range-fillFilled span between the thumbs.
.rui-slider__thumbRange thumb (role="slider").

Theme roles

PartCSS variables consumed
Track--surface
Fill / thumb--primary
Thumb surface--background
Value readout--on-surface
Focus--focus-ring

Accessibility

  • Sliders expose role="slider" with aria-valuenow, aria-valuemin, and aria-valuemax.
  • Pair with a visible label and optionally a live value readout.
  • Arrow keys adjust the value; Page Up/Down jump by larger increments.