ARIA toggle fields do not have accessible names

How to fix the aria-toggle-field-name accessibility rule. ARIA.

The message you saw

Lighthouse and PageSpeed Insights
ARIA toggle fields do not have accessible names
axe-core, axe DevTools and this checker
ARIA toggle fields must have an accessible name (rule aria-toggle-field-name)

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

  1. Run the checker, or search the source for role="switch", role="checkbox", role="radio" and role="option".
  2. Cookie consent banners, settings pages and custom dropdown lists are frequent sources.

How to fix it

  1. If the visible label is inside the element, the element already has a name; check that the text isn’t hidden with aria-hidden.
  2. If the visible label is next to it, give the label an id and point aria-labelledby at it.
  3. If there is no visible label, add aria-label.
  4. 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:

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

More detail