Skip to main content
🎉 A11y Issue Detection Agent is now live! Detect accessibility issues like a WCAG expert with AI. Try now!
No Result Found
Connect and get help from 7,000+ developers on our Discord community. Ask the CommunityAsk the Community

aria-toggle-field-name

Rule Severity : Serious

Description

The aria-toggle-field-name rule ensures that toggle fields (elements with roles such as checkbox, radio, menuitemcheckbox, menuitemradio, or switch) have an accessible name that describes what is being toggled. Without an accessible name, screen reader users cannot determine the purpose of the control.

This rule meets WCAG requirements by:

  1. Providing Programmatic Names (WCAG 4.1.2 Name, Role, Value): It ensures that the name of each toggle control can be programmatically determined by assistive technologies so users understand what they are enabling or disabling.
  2. Conveying Information and Relationships (WCAG 1.3.1 Info and Relationships): It ensures the relationship between a toggle control and its visible label is programmatically exposed, not just conveyed through visual proximity.

To comply with this rule, every toggle field must be associated with a descriptive label using a <label> element, aria-label, or aria-labelledby.

Examples

This example shows a checkbox with no associated label. A screen reader announces the element only as “checkbox”, giving the user no information about what it controls.

Incorrect Sample
Copy icon Copy

Here, a visible label is associated with the checkbox using the <label> element, so screen readers announce “Subscribe to newsletter, checkbox”.

Correct Sample
Copy icon Copy

How to fix?

To fix violations of the aria-toggle-field-name rule, follow these steps:

  • Associate each toggle control with a visible <label> element by linking them with matching for and id attribute values.

  • Alternatively, wrap the toggle control inside a <label> element so the label text is implicitly associated.

  • If a visible label is not possible, add an aria-label attribute directly on the toggle element, or use aria-labelledby to reference a visible element on the page that describes the control.

Reference

We're sorry to hear that. Please share your feedback so we can do better

Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked





Thank you for your valuable feedback

Is this page helping you?

Yes
No

We're sorry to hear that. Please share your feedback so we can do better

Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked





Thank you for your valuable feedback!

Talk to an Expert
Download Copy Check Circle