Skip to content
Search topics

Toggle switches that don't say whether they are on

A switch shows on and off with colour and a sliding knob, but its state is only a CSS class, so assistive technology never hears it.

Broken
On or off? It doesn't say.
The accessibility problem illustrated.
01

The problem

Screen reader users can find the switch but can't tell whether it is on or off, or whether pressing it did anything.

02

Try it

Press Tab to reach the switch, then Space to toggle it.

The panel shows what a screen reader announces. Can you tell whether email updates are on?

Broken Can you fix this?

Screen reader says: (Tab to the switch)

A recreated demo. The broken version is intentionally inaccessible.

03

The fix

Expose the state with a checkbox, aria-checked on a switch, or aria-pressed on a button.

  1. 1Keep the exposed state in step with what is drawn, on every toggle.
  2. 2Keep the name fixed; let the state say on or off.
  3. 3Show on and off by position or text, not by colour alone.
Before A button that draws its state
<button type="button" class="switch" onclick="this.classList.toggle('is-on')">  Email updates</button>
After

A native checkbox styled as a switch

<label class="switch">  <input type="checkbox" name="email-updates" checked>  Email updates</label>

Why this fix: Use native HTML first

04

Verify the fix

5 checks.

Test with: Keyboard, Screen reader, Forced colors, Mouse

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 shared switch component changes.

Limits

This is a starting pattern, not a guarantee for every application. Screen readers word the switch role differently, and some older ones announce it as a checkbox or toggle button. The CSS is a sketch; check the focus indicator and contrast of the track against your own palette. Test the complete settings 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.

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