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 header's cart badge, but the badge is in no live region and the button keeps focus and its name, 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

Screen reader says:

(Press Add to cart)

A recreated demo. The broken version is intentionally inaccessible.

03

The fix

Write what happened into a status region that was on the page before the press.

  1. 1Keep the status region in the page from the start, and change only its words.
  2. 2Say the result in words, success or failure, without moving focus or disabling the button.
  3. 3Announce only what the person did: once per press, and nothing as the page loads.
Before A 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>
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>

Fixing this with an AI coding assistant? Get this guide as Markdown, or get every guide in your coding agent.

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.

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 a topic of its own. 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.

Keep this fixed as your code changes.

Turn guides like this into rules your coding agents and CI follow, then have the result retested with a keyboard and screen readers.

How retests work