Slider

How the Slider works with a keyboard and assistive tech, and where it stands against WCAG 2.2 AA.

FreeReact and VueSlider blocks16 blocksPro
AAWCAG 2.2 target
8/14contrast pairs passing
6keyboard interactions

Each thumb is role="slider" with its minimum, maximum and current value, so it is set from the keyboard with the standard slider keys. Dragging is never the only way: a press on the track moves the nearer thumb there, and the arrow keys step it.

Keyboard#

Tab

Moves focus to the thumb. In a range, to the lower thumb, then the upper.

→

Increases the value by one step. ↑ does the same.

←

Decreases the value by one step. ↓ does the same.

Page Up

Increases the value by a tenth of the range. Page Down decreases it.

Home

Sets the minimum. In a range, the upper thumb stops at the lower one.

End

Sets the maximum. In a range, the lower thumb stops at the upper one.

Semantics#

role="slider"

Focusable, with the value read as it changes.

Each thumb
aria-valuemin, aria-valuemax, aria-valuenow

The range and the current value.

Each thumb
aria-valuetext

The value as it is shown: 40%, $120, 2.5×. Pass formatValue so units are read.

Each thumb
aria-labelledby

Points at the visible label. Without a label, pass aria-label.

label
role="group"

Holds both thumbs under the label. Give each thumb its own name: Minimum price, Maximum price.

Range
aria-disabled

The thumb leaves the tab order and ignores keys and pointer.

disabled
aria-hidden="true"

The visible amount and tooltip repeat aria-valuetext, so they are hidden to avoid reading it twice.

Amount, tooltip

Colour contrast#

Every variant and state has to meet WCAG 2.2 Level AA. Measure the colours as they land on screen: a translucent hover or press wash over whatever sits behind it.

3:1

Fill against the track · Moved

The #005cf8 fill against the #f2f2f2 track, 4.83:1, and against the page. It is what shows the value.

WCAG 1.4.11 Non-text Contrast ↗
3:1

Track and thumb · All

The #f2f2f2 track is 1.12:1 on white, and the white thumb is found only by its shadow. Neither reaches 3:1; at the start, with the centre grey, nothing does.

WCAG 1.4.11 Non-text Contrast ↗
4.5:1

Header text · Label, amount

The label in #2a2a2a and the amount in #6d6d6d pass. (Optional) is #8f8f8f, 3.23:1, and fails.

WCAG 1.4.3 Contrast (Minimum) ↗
3:1

Focus indicator · Focus visible

A 2px ring in #1a6ef8 off a white gap, on keyboard focus only. It measures 4.54:1 on white, so it clears 3:1 on every light surface the library uses.

WCAG 1.4.11 Non-text Contrast ↗WCAG 2.4.13 Focus Appearance ↗
Not required

Disabled · Disabled

The whole slider fades to 40% and is exempt as inactive.

WCAG 1.4.3 Contrast (Minimum) ↗

Measured contrast#

Each part against what sits behind it on a white page, before and after the value leaves the start, from the ds.css tokens; text is held to 4.5:1 and the track, fill and thumb, as graphics, to 3:1. 6 of 14 pairs fall below their minimum (4.5:1 for text, 3:1 for graphics) and are marked in amber.

Part · elementAt the startMoved
Track · on page1.12below the minimum1.12below the minimum
Fill · on track1.00below the minimum4.83passes
Thumb · centre on disc1.12below the minimum5.40passes
Header · label14.35passes14.35passes
Header · amount5.17passes5.17passes
Header · (Optional)3.23below the minimum3.23below the minimum
Tooltip · value20.14passes20.14passes

Motion#

  • The thumb and fill follow the pointer or key with no transition, so there is nothing to reduce.
  • The tooltip appears and disappears without animating.

Checklist#

Give every slider a visible label, and every thumb in a range its own name.

Pass formatValue so aria-valuetext carries units; a bare 40 means little.

Dragging is not required: a press on the track and the arrow keys both set the value (WCAG 2.5.7).

Pair a slider with an Input when the exact number matters.

In a range, each thumb reports the full scale as its minimum and maximum, though it stops at the other thumb. The pattern suggests the other thumb's value instead.

The track (#f2f2f2, 1.12:1) and the white thumb fall under 3:1, and at the start the slider shows no value at all. It needs a darker track or an edge on the thumb before the code library ships.

The thumb is 16px but its hit area is 24px, and the track's band is 24px tall, which meets WCAG 2.5.8.