Slider
<input class="slider" type="range" min="0" max="100" value="40" aria-label="Volume" /><input class="slider" type="range" min="0" max="100" value="40" aria-label="Volume" />Whole steps from 0 to 10.
<div class="field"> <label class="label" for="slider-quality">Quality</label> <input class="slider" type="range" id="slider-quality" min="0" max="10" step="1" value="7" /> <p class="field-description">Whole steps from 0 to 10.</p></div>step controls the granularity and is also what the arrow keys move by.
Disabled
Section titled “Disabled”<input class="slider" type="range" min="0" max="100" value="30" disabled aria-label="Disabled" />How the fill works
Section titled “How the fill works”Firefox paints the filled part natively; Chromium and WebKit have no equivalent. partialkit closes
the difference with a gradient driven by --slider-fill, which the runtime keeps in step with the
value. Nothing to wire up — but it does mean a slider needs the JavaScript to look right, unlike
the rest of the library.
Keyboard
Section titled “Keyboard”| Key | Action |
|---|---|
| ← ↓ | Down one step |
| → ↑ | Up one step |
| Home / End | Minimum / maximum |
| Page Up / Page Down | A larger jump |
All from the platform.
Set dir="rtl" on the page or on any subtree — the track fills from the other end. See
the button page for a live example.
Accessibility
Section titled “Accessibility”- A slider needs a name: a
<label>withfor, oraria-label. - Show the value. A slider with no visible number is guesswork for everyone, and impossible for anyone who cannot see the thumb’s position.
- Do not use a slider for a precise value. Hitting an exact number with a pointer is hard, and harder with a motor impairment. Pair it with a number input when precision matters.