aria-toggle-field-nameCustom checkbox or switch has no name
A custom checkbox, radio button, switch or option with no text or label is announced as just “checkbox, not checked”, with no clue what it controls. Put the label text inside it, or connect a visible label with aria-labelledby.
Who it hurts
Screen reader users, and voice control users who need a name to tick or untick it.
Colour swatches, toggle switches and styled checkboxes are often built with an empty element and the label placed beside it.
How to fix it
Pick your stack. Review every change before you ship it.
Before
<span role="checkbox" aria-checked="false" tabindex="0"></span> SubscribeAfter
<label><input type="checkbox" name="subscribe"> Subscribe</label>Check it by hand too
Tab to each toggle with a screen reader on. You should hear what it controls and whether it is on, such as “Email updates, switch, off”.
Automated checks find a large share of accessibility problems, but not all of them. Passing this check does not on its own make a page compliant.
WCAG reference
- 4.1.2 Name, Role, Value (Level A). Understanding 4.1.2