Range slider
Native range inputs with values, progress, marks and states.
When to use
Use a range slider for an approximate numeric choice within known bounds, such as volume or duration. Use a numeric Input when users need to enter a precise value directly.
Default
Apply .range-slider-input to a labelled native range input. Its output supplements the native value.
<div class="range-slider">
<div class="range-slider-header">
<label class="form-label" for="completion">Completion</label>
<output class="range-slider-output" for="completion">40%</output>
</div>
<input
class="range-slider-input"
id="completion"
name="completion"
type="range"
min="0"
max="100"
step="5"
value="40"
style="--range-slider-progress: 40%" />
<div class="range-slider-marks" aria-hidden="true">
<span>0%</span>
<span>100%</span>
</div>
</div>On input, update <output> and set --range-slider-progress to (value - min) / (max - min) * 100%. The package provides no JavaScript.
Marks
Use .range-slider-marks for reference values. Set aria-hidden when native semantics provide the same information.
Invalid and disabled
For validation, combine .is-invalid, aria-invalid="true" and aria-describedby. Use native disabled.
Right to left
The fill follows direction; the browser retains native behavior and semantics.
Accessibility and behavior
- Label the native range input.
- Use native
min,max,step,valueanddisabled; do not add a slider role. - Update output and progress without replacing native interaction.
- Synchronize
aria-valuetextonly when the spoken value differs.
CSS variables
Override these base defaults on the listed selector after the library styles. Variants and states may replace them; global tokens follow the active theme.
| Token | Default | Purpose | Scope / state |
|---|---|---|---|
--range-slider-gap | var(--spacer-1) | Space between child elements. | .range-slider |
--range-slider-header-gap | var(--spacer-3) | Space between the label and displayed value. | .range-slider |
--range-slider-progress | 0% | Filled percentage; update this alongside the native input value. | .range-slider |
--range-slider-target-size | 2.75rem | Input hit area height. | .range-slider |
--range-slider-track-size | 0.5rem | Track thickness. | .range-slider |
--range-slider-track-bg-color | var(--control-border-color) | Unfilled track color. | .range-slider |
--range-slider-fill-color | var(--primary) | Filled track color. | .range-slider |
--range-slider-thumb-size | 1.5rem | Thumb diameter. | .range-slider |
--range-slider-thumb-bg-color | var(--primary) | Thumb background. | .range-slider |
--range-slider-thumb-border-width | 0.125rem | Thumb border thickness. | .range-slider |
--range-slider-thumb-border-color | var(--on-primary) | Thumb border color. | .range-slider |
--range-slider-thumb-box-shadow | var(--shadow-sm) | Thumb shadow. | .range-slider |
--range-slider-value-color | var(--text-color) | Displayed value text color. | .range-slider |
--range-slider-marker-color | var(--text-muted) | Marker label color. | .range-slider |
--range-slider-disabled-track-bg-color | var(--disabled-border-color) | Unfilled track color while disabled. | .range-slider (disabled) |
--range-slider-disabled-fill-color | var(--disabled-text-color) | Filled track color while disabled. | .range-slider (disabled) |
--range-slider-disabled-thumb-bg-color | var(--disabled-text-color) | Thumb background while disabled. | .range-slider (disabled) |
--range-slider-disabled-thumb-border-color | var(--disabled-bg-color) | Thumb border while disabled. | .range-slider (disabled) |
--range-slider-invalid-color | var(--error) | Accent color for invalid controls and feedback. | .range-slider (invalid) |
--range-slider-focus-outline-width | var(--focus-outline-width) | Focus ring thickness. | .range-slider (focus) |
--range-slider-focus-outline-style | var(--focus-outline-style) | Focus ring line style. | .range-slider (focus) |
--range-slider-focus-outline-color | var(--focus-outline-color) | Focus ring color. | .range-slider (focus) |
--range-slider-focus-outline-offset | var(--focus-offset) | Distance between the focus ring and control. | .range-slider (focus) |
--range-slider-transition-duration | var(--transition-duration) | Duration of visual state transitions. | .range-slider |
--range-slider-transition-easing | var(--transition-easing) | Timing curve for visual state transitions. | .range-slider |