ARIA toggle fields do not have accessible names
How to fix the aria-toggle-field-name accessibility rule. ARIA.
The message you saw
Lighthouse runs axe-core inside it, so both are the same check, and the fix below works whichever tool showed you the message.
What it means
A toggle field is anything that can be switched on and off or chosen from a set. When it is built with ARIA instead of a real <input>, it has one of these roles: checkbox, switch, radio, menuitemcheckbox, menuitemradio or option. This message means one of them has no name: no text inside it and no aria-label, aria-labelledby or title.
As with other custom controls, a <label for="…"> doesn’t name it. HTML labels only work with real form elements.
Who is affected
A custom checkbox, radio button, switch or option (built with ARIA roles) has no name, so it is announced as just "checkbox" or "switch".
Screen-reader users hear “switch, off” or “checkbox, not checked” without knowing what it turns on or agrees to. That matters a lot for consent and settings toggles. Voice-control users can’t name it to click it.
How to find it
- Run the checker, or search the source for
role="switch",role="checkbox",role="radio"androle="option". - Cookie consent banners, settings pages and custom dropdown lists are frequent sources.
How to fix it
- If the visible label is inside the element, the element already has a name; check that the text isn’t hidden with
aria-hidden. - If the visible label is next to it, give the label an
idand pointaria-labelledbyat it. - If there is no visible label, add
aria-label. - Where you can, use a real
<input type="checkbox">or radio button with a<label>: it’s named, focusable and announced correctly without extra code.
Example
Before
<div role="switch" aria-checked="false" tabindex="0"></div>
<span>Dark mode</span>After
<div role="switch" aria-checked="false" tabindex="0"
aria-labelledby="dark-label"></div>
<span id="dark-label">Dark mode</span>WCAG success criteria
When this rule fails, the page fails:
- 4.1.2 Name, Role, Value (Level A, WCAG 2.0, 2.1, 2.2)
Check your fix
Scan a web page and the report lists every element that fails this rule, with screenshots outlining where they are, the code, and a selector you can paste into your browser’s developer tools. Scan again after your change: when the rule no longer appears under the problems, the fix worked.
An automated pass means this rule found nothing wrong. It doesn’t prove the page is accessible: some of what WCAG asks for needs a person to check, and the report’s manual checklist lists those steps.
Related fix guides
- ARIA input fields do not have accessible names
[role]s do not have all required[aria-*]attributes- Form elements do not have associated labels
button,link, andmenuitemelements do not have accessible names
More detail
- Deque University’s reference for aria-toggle-field-name (the makers of axe-core, the engine our scanner uses)
- W3C’s Understanding 4.1.2
- All fix guides