Slider
Sets a value on a continuous range, for thresholds that are judged rather than typed.
Try it
Drag the handle, or tab to it and use the arrow keys, Home or End.
<WildSlider
v-model="threshold"
label="Refill threshold"
:min="0"
:max="100"
:step="1"
size="md"
color="blue"
show-value
:format-value="(n) => `${n}%`"
/>When to use
- Use a slider for a value that’s judged rather than typed, such as a refill threshold set by where the line usually sits.
- Turn on ticks only where the value is stepped.
- Keep it blue. Green, amber and red already mean state in this product.
- For a figure read off a datasheet, such as a calibration offset. Use a numeric input.
Anatomy
A label and an optional value badge, the track and its fill, and the handle. With ticks on, the min and max sit underneath.
<WildSlider v-model="v" />
<WildSlider v-model="v" label="Refill threshold" show-value />
<WildSlider v-model="v" label="Refill threshold" show-value show-ticks :step="10" />Sizes
Tracks of 4, 6 and 8px, with 16, 20 and 24px handles. The default is md.
<WildSlider v-model="v" size="sm" />
<WildSlider v-model="v" size="md" />
<WildSlider v-model="v" size="lg" />md takes the lg track and handle, for touch.Ticks
Up to 11 marks, each on a value the handle can stop on. Ticks bring the min and max labels with them.
<WildSlider v-model="v" :min="0" :max="100" :step="10" show-ticks />
<WildSlider v-model="v" :min="1" :max="10" :step="1" show-ticks />Colour
Five fills. Each one colours the handle’s ring and its focus ring too.
States
Hover and focus lift the handle, and focus adds a ring. Disabled greys the fill but keeps the value readable.
<WildSlider v-model="v" label="Normal" show-value />
<WildSlider v-model="v" label="Locked setting" show-value disabled />Accessibility
It’s a native range input, named by label or ariaLabel, and it announces the formatted value. The pointer target is 24px tall at every size.
| Key | What it does |
|---|---|
| Tab | Moves focus to the handle. |
| ← / ↓ | Steps down by one step. |
| → / ↑ | Steps up by one step. |
| Home / End | Jumps to the min or the max. |
| Page Up / Page Down | Moves by a larger stride. |
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| value / defaultValue | number | 0 | The value, controlled or uncontrolled. |
| onChange | (value: number) => void | — | Fires throughout a drag, not only on release. |
| min / max | number | 0 / 100 | The range. |
| step | number | 1 | Increment, and the arrow-key stride. |
| size | 'sm' | 'md' | 'lg' | 'md' | Track 4, 6 or 8px; handle 16, 20 or 24px. |
| color | 'blue' | 'green' | 'orange' | 'red' | 'purple' | 'blue' | Fill, handle ring and focus ring. |
| disabled | boolean | false | Greys it out; blocks pointer and keyboard. |
| showValue | boolean | false | The value badge in the header. |
| showTicks | boolean | false | Step marks, plus the min and max labels. |
| label | string | — | Header text. Also names the slider. |
| formatValue | (value: number) => string | — | Formats the badge and the spoken value. |
| ariaLabel | string | — | Accessible name when there is no label. |
Tokens
| Token | Value | Where it lands |
|---|---|---|
| --global-blue-1000 | #1877F2 | Fill, handle ring and focus ring, blue. 3.59:1 on the track. |
| --global-green-900 | #018030 | Green. |
| --global-squash-900 | #C47E0A | Orange. |
| --global-red-800 | #E12121 | Red. |
| --global-purple-900 | #7B238D | Purple. |
| --global-neutral-grey-400 | #ECECED | The unfilled track. |
| --global-neutral-grey-900 | #7F7D83 | Ticks on the track. White on the fill. |
| --global-neutral-grey-200 / -1000 | #F5F5F5 / #4F4D55 | Value badge ground and ink. |
| --global-neutral-grey-1100 | #2D2B32 | The label. |
| (no token) | #4F4D55 | Min and max labels. |
| --global-neutral-grey-300 / -800 | #F1F1F1 / #ADACB0 | Disabled track; disabled fill and ring. |
| --global-neutral-grey-700 | #C9C9CC | The label when disabled. |
| (no token) | 0 2px 4px rgba(10,9,11,.1) | Handle shadow. Hover deepens it. |
| (no token) | 2px gap, 2px ring | Keyboard focus, around the handle. |
| (no token) | 0.15s ease | Handle lift and shadow. |