Skip to content
easeweb
Search topics

Quantity steppers with unnamed buttons and no typing

A quantity's minus and plus are unnamed buttons or click-only spans, and the number can't be typed, so a screen reader hears no names and nobody can enter it.

WCAG 2.2
SC 4.1.2ASC 2.1.1A
Required by
Section 508 · EN 301 549 (EU)
Broken <button type="button" class="step"><svg>…</svg></button>
The accessibility problem illustrated: No vision:Which button adds a mug?
01

The problem

Screen reader users can't tell which button adds a mug and which takes one away, nobody can type a quantity, and where the minus and plus are click-only spans, keyboard users can't change it at all

02

Try it

Set the quantity to 4 without the mouse

  • Broken 1: Tab to the stepper, then type 4, or use its buttons or the up arrow. What are the two buttons called, and can you type a number? The panel shows what a screen reader says.

  • Broken 2: Tab to the quantity, type 4 or press the up arrow, and try to Tab to the minus and plus. Then click them with the mouse.

  • Apply a fix. Set the quantity to 4 with the keyboard again, and watch what the panel says for each control.

Broken Can you fix this?

Enamel mug $18

Quantity
1

A recreated demo. The broken version is intentionally inaccessible.

03

The fix

Name the − and + buttons, and let the quantity be typed

Before

Unnamed icon buttons around a printed number

<form class="buy" action="/basket" method="post">  <span class="qty-label">Quantity</span>  <div class="stepper">    <button type="button" class="step" data-step="-1">      <svg class="icon" viewBox="0 0 16 16">…</svg>    </button>    <span class="qty">1</span>    <button type="button" class="step" data-step="1">      <svg class="icon" viewBox="0 0 16 16">…</svg>    </button>  </div>  <input type="hidden" name="quantity" value="1">  <button type="submit">Add to bag</button></form>
What is wrong3 points
  • Both buttons are read only as "button", so nobody can tell which one adds a mug. Each holds only an SVG with no title, so its name is empty.
  • A press doesn't say what the number has become. The quantity is a span and a hidden input, so it is not read with the buttons.
  • Nobody can type the quantity they want, so ten mugs take nine presses of plus. The number is printed text, not a field.
After

Named buttons around a number field

<form class="buy" action="/basket" method="post">  <label for="qty" class="qty-label">Quantity</label>  <div class="stepper">    <button type="button" class="step" data-step="-1">      <svg class="icon" viewBox="0 0 16 16" aria-hidden="true">…</svg>      <span class="visually-hidden">Decrease quantity</span>    </button>    <input id="qty" name="quantity" type="number" min="1" max="10" value="1">    <button type="button" class="step" data-step="1">      <svg class="icon" viewBox="0 0 16 16" aria-hidden="true">…</svg>      <span class="visually-hidden">Increase quantity</span>    </button>  </div>  <button type="submit">Add to bag</button></form>
How it is fixed5 steps
  1. Make the minus and plus buttons, which Tab reaches and Enter and Space press.
  2. Hide each icon, and put the button's words in visually hidden text. Each button now says what it does, "Decrease quantity, button", and its icon adds nothing to the name.
  3. Make the number a real field, labelled and without readonly. It is read as "Quantity, spin button, 1", people can type 10 straight in, and the up and down arrows step it.
  4. Remove the hidden input: the field is now what the form sends.
  5. Step the field with stepUp() and stepDown(), which stop at min and max, so the buttons can't take the number under 1 or past 10.

This fixes both Befores and passes 4.1.2 and 2.1.1. For the second build it is also the smallest change: the spans become these buttons, and readonly goes. The design keeps its round buttons. If it shows only those, the browser's own spin arrows can be hidden with CSS; the arrow keys keep working, because they belong to the field, not to the arrows.

Why this fix: Use native HTML first

04

Design ideas

A light, modern stepper can still be read and typed into

Four ways to draw the mug’s quantity. Click each one, then put the mouse aside and Tab to it: three can be set from the keyboard and say what they are, and one only answers a pointer.

In the design file

  • Write each button’s name beside it, such as Decrease quantity and Increase quantity, or Remove for a bin.
  • Draw the number as a box that can be typed into, with the caret and the focus ring in it.
  • Give the quantity its label, Quantity, even where the design doesn’t show it.
  • Draw the stepper at its lowest and highest quantity, with both buttons still there.

Passes

  • One pill, the number typed in the middle The minus, the number and the plus share one 46px pill in a soft #f1f3f5 grey with a #8a929c edge, 3.15:1 on white, the buttons white circles inside it. The number is a field with no box of its own: a click or Tab puts the caret in it, and the whole pill takes the focus ring.
  • Enamel mug $18
    A bin in place of the minus at 1 In a basket row, the minus turns into a bin when the quantity is 1, so the same place removes the item. Its name changes with its icon, from “Decrease quantity” to “Remove Enamel mug”, and the row that replaces the item offers Undo.
  • A dropdown of quantities “Quantity 1” in a navy-edged pill, as many large shops draw it, is the browser’s own dropdown under the styling: a tap opens the system’s list, Tab reaches it and the arrow keys choose from it, and it is read with its label and value. It suits a small limit; past about ten, typing is quicker than a long list.

    Rule of thumb: Use native HTML first

Fails

  • Quantity 1
    Small chevrons stacked beside the numberWCAG 2.1.1 A compact counter: the number in a box with an up and a down chevron stacked beside it, drawn as icons that only a click answers. Tab goes straight past them, nothing can be typed, and a screen reader finds no control, so without a pointer the number stays at 1.
05

Verify the fix

5 checks, no mouse.

Test with: Keyboard, Screen reader, 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 stepper component or the theme changes.

Limits

This is a starting pattern, not a guarantee for every application. Screen readers name a number field's role in different words, and some read its number before its label. Steppers that set a guest count, a number of nights or a time follow the same pattern, but a stepper that steps through words, such as sizes, is a different control: a select or a group of radio buttons. If your control moves along a track, see range sliders that only move by dragging; for icon buttons elsewhere on the page, such as a header's search and menu, see icon-only buttons with no accessible name. Some screen readers call a span with a click handler "clickable" while reading the page, and click it when Enter is pressed; that is the screen reader working round the markup, and it gives the span no name and no Tab stop. Test the full journey from product page to basket 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