Slider
Slider captures one value on a scale. The thumb tracks a pointer drag; the arrow keys step it by
step. It carries the full role="slider" ARIA and no styling.
What it is
A single forwardRef component — not compound. It renders a role="slider" track with two
absolutely-positioned children, the fill and the thumb, each styled through its own prop. Values
are clamped to [min, max] and snapped to step. The track responds to both pointer drags and
the keyboard.
Install
API
Slider
stableconst Slider: ForwardRefExoticComponent<SliderProps & RefAttributes<HTMLDivElement>>
The value, controlled or uncontrolled.
The scale bounds and the increment. Values are clamped and snapped.
Track orientation — decides which arrow keys increment and how the fill grows.
Removes the slider from the Tab order and ignores input.
Names the slider. One is required — a slider with no name is unidentifiable.
Inline styles for the track wrapper, the thumb, and the filled portion.
Keyboard
| Key | Action |
|---|---|
| Arrow Right / Up | Increase by step |
| Arrow Left / Down | Decrease by step |
| PageUp / PageDown | Change by ten steps |
| Home / End | Jump to min / max |
Accessibility
Slider is a role="slider" carrying aria-valuenow, aria-valuemin, and aria-valuemax, so a
screen reader announces the current value against its range. It needs a name — aria-label or
aria-labelledby — and it is keyboard-operable through the arrow keys, PageUp/Down, and Home/End.
A disabled slider drops out of the Tab order.
Examples
A volume control: