Skip to content
easeweb
Search topics

Range sliders that only move by dragging

A price slider's thumbs are plain elements moved by pointer events, so they can't be focused, have no value a screen reader can read, and need dragging.

WCAG 2.2
SC 2.1.1ASC 4.1.2ASC 2.5.7AA· new in 2.2
Required by
Section 508 · EN 301 549 (EU)
Broken <span class="thumb">
The accessibility problem illustrated: Motor:How do I move the price?
01

The problem

People who can't drag, and screen reader users, can't set the price range or find out what it is

02

Try it

Drag a thumb to change the price range. Then put the mouse aside and try it with Tab and the arrow keys

The panel shows what a screen reader announces. Can you set a price without dragging, and do you hear it?

Broken Can you fix this?

BrokenTwo thumbs moved only by dragging

Price$20 – $160

A recreated demo. The broken version is intentionally inaccessible.

03

The fix

Name each end, and let it be set without dragging

Before
BrokenTwo thumbs moved only by dragging
<div class="price">  <span class="price-label">Price</span>  <span class="price-values">$20 – $160</span>  <div class="track">    <span class="thumb" data-thumb="min" style="left: 10%"></span>    <span class="thumb" data-thumb="max" style="left: 80%"></span>  </div></div>
What is wrong3 points
  • The keyboard can't reach the thumbs. They can't take focus.
  • Assistive technology isn't told that the thumbs are controls, or where they are set. They have no role, name or value.
  • People who can't drag can't set any price. The only input the script takes is a pointer held down on a thumb and moved.
After

Two native range inputs

<fieldset class="price">  <legend>Price</legend>  <label for="price-min">Minimum</label>  <input type="range" id="price-min" min="0" max="200" step="10" value="20" aria-valuetext="$20">  <output for="price-min">$20</output>  <label for="price-max">Maximum</label>  <input type="range" id="price-max" min="0" max="200" step="10" value="160" aria-valuetext="$160">  <output for="price-max">$160</output></fieldset>
How it is fixed4 steps
  1. Replace each thumb with an input type="range". The browser gives each input focus, the arrow keys, Page Up, Page Down, Home and End, and a role and value a screen reader reads. A click or tap on the track moves the thumb there, and because that is the browser's own behaviour, 2.5.7 leaves it to the browser.
  2. Put the two inputs in a fieldset with the legend Price, and label each one, so each end is named "Price, Minimum".
  3. Set aria-valuetext and the output from the value on every input event, so the value reads as "$20" rather than "20".
  4. In the same handler, stop each end at the other, so the minimum never passes the maximum.

This fixes the Before and passes 2.1.1, 4.1.2 and 2.5.7. The cost is the look: two tracks, one under the other, rather than one with two thumbs. Don't lay the two inputs over each other on one track with pointer-events: none: that turns off the click on the track, and the drag becomes the only pointer action again. Of the extras a custom slider is kept for, the native inputs can take branded thumbs: accent-color colours them, ::-webkit-slider-thumb and ::-moz-range-thumb style the thumb itself, and the output beside each input already shows its value.

Why this fix: Use native HTML first

04

Design ideas

A sleek slider can still work without a drag

Four ways to draw the shop’s price filter. Try each with clicks only, then Tab to it and use the arrow keys: three can be set with a click, and one only moves while the pointer is held down.

In the design file

  • Draw each handle with the focus ring around it.
  • Give each handle a name the developer can use, such as Minimum price and Maximum price.
  • Show each handle’s value as text with its unit, “$20”, not “20”.
  • Make each handle at least 24 by 24 pixels to tap. The tappable area can be larger than the handle you draw.
  • Draw the slider in a Windows contrast theme, where the handles and the selected range still have an outline.

Passes

  • Price $20 – $160

    A price histogram over the track Twenty bars over the track, one for each $10, show where the prices cluster: navy inside the range, grey outside it. The bars are part of the track, so a click or tap on one moves the nearer thumb there.
  • Price

    The price on each thumb Each thumb carries its price in a navy pill, so the value sits where the eye, and a magnifier, already are, and the separate price line can go. The pill follows a click on the track and the arrow keys, not only a drag.
  • Price $20 – $160

    Preset ranges above the slider Three 32px pills set both ends in one tap for the ranges most people pick, and the pill that matches the range is filled. The slider under them covers every other range, with a click on the track and the arrow keys.

Fails

  • Price $20 – $160

    Two browser sliders stacked on one trackWCAG 2.5.7 It looks like one track with two thumbs, and Tab and the arrow keys work. But making the two inputs share the track turns off the browser’s click on it, so a click or tap on the track does nothing and every pointer change is a drag.
05

Verify the fix

5 checks.

Test with: Keyboard, Screen reader, Mouse, Touch

0 of 5 checked

Record the OS, browser and assistive-technology versions, the build, the date, and the actual result of each step. Repeat after the slider component or its library changes.

Limits

This is a starting pattern, not a guarantee for every application. Screen readers differ in how they read range inputs and custom sliders: some read the value before the name, and some on iOS move a slider by swiping up and down rather than with keys. Sliders that pick a colour are covered in colour pickers you can only drag, with no field to type; sliders that set a time on a media player or resize a panel have needs of their own and are not covered here. If your "slider" is a row of slides with arrows, see carousels that keyboard and screen reader users can't use. Test the complete filter journey with your target assistive technology.

This is a recreated teaching example, not a finding about a named client. The code is a starting pattern: test it in your own product. No completed assistive-technology test is claimed here.

EaseWeb service

Fixed it? Keep it from coming back.

I turn guides like this one into rules your coding agents follow and checks your CI runs. Then I retest by hand with a keyboard and screen readers, periodically.

See the service