Skip to content

Find what you need, instantly

Search components, ARIA roles & attributes, and WCAG criteria.

Forms & Controls

Slider

A control for selecting a value from a continuous or discrete range.

Last verified against WCAG 2.2 and WAI-ARIA APG 1.2 on 2026-07-02.

Implementation

slider-pattern.tsx
function SliderPattern() {
  const [value, setValue] = useState(60);

  function onKeyDown(e) {
    if (e.key === "ArrowRight" || e.key === "ArrowUp") { e.preventDefault(); setValue(v => clamp(v + STEP)); }
    else if (e.key === "ArrowLeft" || e.key === "ArrowDown") { e.preventDefault(); setValue(v => clamp(v - STEP)); }
    else if (e.key === "PageUp") { e.preventDefault(); setValue(v => clamp(v + BIG_STEP)); }
    else if (e.key === "PageDown") { e.preventDefault(); setValue(v => clamp(v - BIG_STEP)); }
    else if (e.key === "Home") { e.preventDefault(); setValue(MIN); }
    else if (e.key === "End") { e.preventDefault(); setValue(MAX); }
  }

  return (
    <div onPointerDown={(e) => setFromClientX(e.clientX)}> {/* click-on-track jump */}
      <div
        role="slider"
        tabIndex={0}
        aria-labelledby="volume-label"
        aria-valuemin={MIN}
        aria-valuemax={MAX}
        aria-valuenow={value}
        aria-valuetext={`${value}%`}
        onKeyDown={onKeyDown}
      />
    </div>
  );
}

Live demo

Required roles, states & properties

Required roles, states, and properties
ElementAttributeWhy
Thumbrole="slider"Identifies the focusable thumb element as a slider control to AT.
Thumbaria-valuemin / aria-valuemaxCommunicates the slider's minimum and maximum possible values.
Thumbaria-valuenowCommunicates the current numeric value, updated on every change.
Thumbaria-valuetextOverrides the announced value with a human-meaningful string when the raw number alone isn't meaningful (e.g. "Medium" instead of "2"); here it's used to announce "60%" instead of a bare "60."
Thumbaria-labelledby / aria-labelGives the slider an accessible name, e.g. "Volume," so it isn't announced as an unnamed slider.
ThumbtabIndex={0}Makes the thumb keyboard-focusable, since a bare <div> is not focusable by default.

Keyboard interaction model

Keyboard interaction model
KeyBehavior
Right Arrow / Up ArrowIncreases the value by one step.
Left Arrow / Down ArrowDecreases the value by one step.
HomeJumps to the minimum value.
EndJumps to the maximum value.
Page UpIncreases the value by a larger step (10x the normal step, for sliders with a wide range).
Page DownDecreases the value by a larger step.

Focus management rules

  • The thumb itself is the single Tab stop for the whole control — there's nothing else to tab through.
  • Clicking anywhere on the track moves focus to the thumb and jumps the value to that position.
  • Focus never leaves the thumb while dragging or using arrow keys; the value updates in place.
  • A visible focus ring on the thumb must remain visible at every value, including at the min/max ends of the track.

WCAG 2.2 success criteria mapping

WCAG 2.2 success criteria that apply to this component
SCNameLevelWhy it applies
2.1.1KeyboardAAll functionality is operable through a keyboard interface with no specific timing.
2.5.7Dragging MovementsAAFunctionality using a dragging movement has a single-pointer alternative (e.g. slider with buttons).
4.1.2Name, Role, ValueAFor all UI components, name, role, and value are programmatically determinable; states and changes are announced.

References