Live demo
Demo source
Use a slider when people choose a value from a continuous range and an
approximate position is enough, such as a power limit or a price range. Set
range to choose a start and an end. For an exact number, use a
number field, or add a number input with
hasField.
Anatomy
A slider with seven callouts: 1 the label Midi-chlorian counts, 2 the description, 3 the error description, 4 the track, 5 the round thumb, 6 the tick marks below the track, and 7 a number field showing 500 W.
- Label names the value;
hideLabelhides it visually only. - Description (optional) adds context.
- Error description explains an invalid value.
- Track spans
mintomax. - Thumb shows and sets the value; a range has two. Arrow, Page, Home and End keys move it.
- Ticks (optional) mark steps with
showTicks, or custom values with labels throughticks. - Number field (optional,
hasField) shows the value and accepts typing, with a unit fromlabelBeforeValueorlabelAfterValue.
Values and states
The value is always an array: one number, or two for a range. step and
snap control how values move. Disabled sliders cannot be used, and
read-only ones remain focusable but keep their value unchanged. Set error
with an errorDescription, or success after validation. Pair the colour
change with text so the result is understandable without colour alone.
Use labelBeforeValue or labelAfterValue for context such as a currency or
unit. fluid removes the default 480 px width limit. hideLabel hides the
label visually; keep a meaningful label available to assistive technology.
Guidelines
- Add a clear label and a unit.
- Use steps and ticks that suit the data.
- Pair a number field with the slider when people need an exact value, and
configure
stepandsnapfor the required precision. - Keep validation messages and units visible; colour alone is insufficient.