Slider
A native <input type="range"> styled via class + data attributes. Two variants, three sizes, color theming. Filled track works in every modern browser with zero JS.
The fill is painted differently per engine: Firefox uses the native ::-moz-range-progress pseudo; WebKit uses Ana Tudorβs box-shadow trick β a massive horizontal box-shadow on the thumb, clipped by overflow: hidden on the input. As the thumb moves, the shadow moves with it.
Install
import "elements-kit/ui/styles.css";
import "elements-kit/ui/styles/palette/gray.css";import "elements-kit/ui/styles/neutral/gray.css";import "elements-kit/ui/styles/palette/black-alpha.css";import "elements-kit/ui/styles/palette/mint.css";import "elements-kit/ui/styles/accent/mint.css";
import "elements-kit/ui/slider/slider.css";API
<input type="range" class="unset x-slider" min="0" max="100" value="50" data-size="2" data-variant="surface"/>| Attribute | Values |
|---|---|
data-variant | surface (default), soft |
data-size | 1, 2 (default), 3 |
data-accent (on a parent or the input) | any imported color scale |
disabled / data-disabled | native or attribute |
Sizing
data-size | track | thumb |
|---|---|---|
1 | --space-2 Γ 0.75 (~6px) | track + --space-1 (~10px) |
2 (default) | --space-2 (~8px) | track + --space-1 (~12px) |
3 | --space-2 Γ 1.25 (~10px) | track + --space-1 (~14px) |
Thumb shape: border-radius: max(--radius-1, --radius-thumb) β sits flush with the pageβs data-radius setting.
Variants
surface(default) β bordered track,--neutral-a3background, 1px--neutral-a5border.softβ flat track,--neutral-a4background, no border, thumb has tinted shadow.
Focus
:focus-visible adds a 3px --accent-3 ring + 5px --focus-8 outline around the thumb. The native track outline is suppressed.
Limitations
The kit ships a single-thumb range input.
- Slight vertical bleed of the fill β the WebKit box-shadow trick paints fill at the inputβs height (= thumb height). The fill extends ~
(thumb β track) / 2px above and below the visible track. Negligible at default sizes. - No range (X-to-Y) slider β needs two thumbs + JS. Caller composes.
- No vertical orientation β
appearance: slider-verticalis inconsistent across browsers. - No tick marks / step indicators β render your own
<datalist>if needed.
Accessibility
<input type="range">is keyboard-accessible by default β arrow keys move bystep, home/end jump to min/max.- Pair with a
<label>(wrapping orfor=). - Set
aria-valuetextif the displayed value differs from the inputβs raw number (e.g. β$1,200β instead of1200).