Skip to content
easeweb
Search topics

Add to cart buttons that change a badge and say nothing

Add to cart raises the number on the cart badge, but the badge is in no live region and the button stays the same, so a screen reader says nothing.

WCAG 2.2
SC 4.1.3AA· new in 2.1
Required by
EN 301 549 (EU)
Broken cartCount.textContent = cart.count;
The accessibility problem illustrated: No vision:Did it go in my cart?
01

The problem

Screen reader users press Add to cart and hear nothing, so they can't tell whether the item went in, and press again or leave the page to check

02

Try it

Press Add to cart and listen

The panel shows what a screen reader says. The shop takes a moment to answer: do you hear anything while it does, or that the mug went in? Then press twice quickly and watch the badge.

Broken Can you fix this?

BrokenA badge that changes in silence

Enamel mug

$18

A recreated demo. The broken version is intentionally inaccessible.

03

The fix

Write the result into a status region already on the page

Before
BrokenA badge that changes in silence
<header>  <a href="/" class="logo">Larkfield</a>  <a href="/cart" class="cart">    <svg aria-hidden="true">…</svg>    <span class="visually-hidden">Cart</span>    <span id="cart-count" class="badge">0</span>  </a></header><main>  <h1>Enamel mug</h1>  <p class="price">$18</p>  <button type="button" id="add">Add to cart</button></main>
What is wrong4 points

The number is right once the server answers. The rest goes wrong.

  • The new number is never announced, because the span is not a live region.
  • A screen reader says nothing during the wait or after it, because nothing about the focused button changes either.
  • A second press while the first is on its way adds a second mug, because nothing ignores presses during the wait.
  • A failed add goes unnoticed: nothing on the page changes at all.
After

A confirmation line beside the button

<header>  <a href="/" class="logo">Larkfield</a>  <a href="/cart" class="cart">    <svg aria-hidden="true">…</svg>    <span class="visually-hidden">Cart</span>    <span id="cart-count" class="badge">0</span>  </a></header><main>  <h1>Enamel mug</h1>  <p class="price">$18</p>  <button type="button" id="add">Add to cart</button>  <p id="add-status" role="status"></p></main>
How it is fixed5 steps
  1. Add an empty p with role="status" under the button, in the HTML from the start, so the browser is already watching it when its text changes.
  2. Ignore presses while one is on its way, and leave the button enabled. Focus stays on it, and a press during the wait doesn't add a second mug.
  3. If the shop takes more than half a second to answer, write "Adding the enamel mug…", so the wait is not silent either. A quick answer skips it, so people aren't told twice.
  4. When the mug is added, write "Enamel mug added. 1 item in your cart." The screen reader finishes what it is saying, then reads it. Each press changes the count in the sentence, so a second press is announced too.
  5. When adding fails, write "The mug was not added. Please try again.", so a failed add gets its own words instead of silence.

This fixes the Before and passes 4.1.3. The line sits under the button, where a magnifier user is already looking and where a sighted user who has scrolled past the header can see it, and it can stay there until the page changes.

Easily confused
04

Design ideas

A confirmation can be quick, and still be said

Four ways to show that Add to cart or Copy link worked. Press each one: two put what happened into words a screen reader is also given, and two show it only as a picture.

In the design file

  • Write the sentence each action confirms with, such as “Enamel mug added. 1 item in your cart.”, even where the screen shows only a tick, a number or a moving picture.
  • Draw what the button shows while the shop answers, at the width of its label and still looking like a button.
  • Write the message for when it fails next to the one for success.
  • Write the ratios next to the confirmation’s colours, at least 4.5:1 for its words.

Passes

  • Enamel mug $18
    A button that says Added The label turns to a small spinner and “Adding…”, then a tick and “Added” on a pale green (6.46:1) for two seconds, at the same width so nothing jumps. Screen readers read a focused button’s new label in some setups only, so the same sentence also goes into a hidden status line.
  • Enamel mug $18
    A toast with the product’s photo A dark pill rises from the bottom with the mug’s photo and “Enamel mug added. 1 item in your cart.” in white, 14.81:1, and stays six seconds. It is drawn inside a status area that is on the page before anything is added, so it is read as it appears.

Fails

  • Larkfield Cart 0 Enamel mug $18
    The photo flies into the bagWCAG 4.1.3 A copy of the photo shrinks into the bag in half a second and the number on the bag bounces. The movement shows the change and stops, but it is the only sign: no words, so a screen reader says nothing, and with reduced motion only the number changes.
  • Enamel mug $18 Share this mug
    A Copy link icon that turns into a tickWCAG 4.1.3 The chain icon flips to a tick for two seconds, then back. Nothing is in words, so a screen reader hears nothing, and a tick alone may not say “copied” to anyone. Write “Link copied” beside it into a status line, and say so when copying fails.
05

Verify the fix

4 checks, no mouse.

Test with: Screen reader, Keyboard, Zoom

0 of 4 checked

Record the OS, browser and assistive-technology versions, the build, the date, and the actual result of each step. Repeat after the header, the product template or the cart script changes.

How screen readers handle role="status"

Limits

Live regions behave differently across screen readers and browsers, especially regions inside links, moved regions and regions inside dialogs. This pattern covers one button on one product page. Naming the cart's own buttons is covered in icon-only buttons with no accessible name, and the quantity next to Add to cart in quantity steppers with unnamed buttons and no typing. A form that sends and shows its result, such as a newsletter sign-up, is covered in form success and error messages that are never announced. Test your real cart, with its drawer, quick-add buttons and phone header, with the screen readers your users use.

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