Slider
ExpressiveChooses a value or a range on a continuous or stepped scale, in five sizes.
import { Slider, RangeSlider } from '@windmorph/react';Keyboard
| Key | Action |
|---|---|
| Tab | Moves focus to the thumb, and on to the next element. A range slider has two thumbs, each its own Tab stop. |
| Arrow Right or Arrow Up | Increases the value by step. |
| Arrow Left or Arrow Down | Decreases the value by step. |
| Page Up or Page Down | Increases or decreases the value by a larger interval, a tenth of the range by default. |
| Shift + Arrow Right or Space + Arrow Right | Holding Shift or Space while pressing any arrow key moves by the larger interval too. |
| Home or End | Moves the thumb to the minimum or the maximum. |
- In a right-to-left layout Arrow Left and Arrow Right swap, so the arrow always points the way the thumb moves.
- The thumbs of a range slider can't pass each other.
Screen reader
- Role
grouparound onesliderper thumb: each thumb is a visually hidden native range input (React AriauseSlider/useSliderThumb).- Accessible name
aria-label, oraria-labelledbypointing at a visible label; the types require one. Each thumb is named as the group is: witharia-labelledbyit points at the label itself, so it's read as the label, never as its value. A range slider puts each thumb's own name fromlabels(default "Minimum" and "Maximum") before the slider's: "Minimum Price".aria-describedby,aria-detailsandaria-errormessagereach every thumb, so helper or error text is read as each one takes focus.- States announced
- The value, minimum and maximum, the orientation (
aria-orientation), and disabled. The announced value (aria-valuetext) is formatted withformatOptions, or said in words byvalueText, which gets each thumb's value and index (a time: "1 minute 25 seconds of 10 minutes").
The track, stop indicators, ticks, inset icons and the value indicator pill are decorative and hidden from assistive tech (aria-hidden).
Focus
- Each thumb is in the Tab order. A disabled slider can't be focused.
- Keyboard focus shows M3's focus indicator around the handle: a 3px
secondaryoutline 2px outside it, with the gap to the track widened from 6px to 10px to make room. The handle narrows from 4px to 2px, as it does while dragged. - With
valueLabel, the value indicator shows while a thumb is dragged or has keyboard focus. Pointer presses show no ring.
Touch target
- Pressing anywhere on the track moves the nearest thumb there, so the hit area is the full length of the track.
- It is as tall as the handle: 44px for XS and S, and 52, 68 and 108px for M, L and XL. An XS or S slider takes presses 2px past its edges on each side, so its hit area is 48px tall without changing its layout; leave 2px clear above and below it.
Motion
None. The slider has no animation: the thumb and tracks follow the value directly, so reduced motion changes nothing.
What you need to do
- Name every slider with
aria-label, oraria-labelledbypointing at a visible label. - Link helper or error text shown beside the slider with
aria-describedby. - For a range slider, pass
labelswhen "Minimum" and "Maximum" don't fit, or to translate them. - Pass
formatOptionswhen the number alone is unclear (a percentage, a currency), so the value is announced with its unit. - When the exact value matters, show it (
valueLabel, or a text field beside the slider) rather than relying on the track position.