ARIA toggle fields have accessible names

Toggle controls have labels that screen readers can announce.

On this page

Impact

ScanGov impact ratings

About

When a toggle field doesn't have an accessible name, screen readers announce it with a generic name, making it unusable for users who rely on screen readers.

Risks

Screen readers cannot tell users what a toggle switch controls.

Why it's important

Ensures assistive technologies like screen readers can correctly interpret and announce page elements to users with disabilities.

User stories

As a screen reader user, I want ARIA attributes to be correctly implemented so that I can understand the purpose and state of interactive elements.

Code

Failing pattern:

<!-- Fail: switch with no accessible name -->
<input type="checkbox" role="switch">

Passing pattern:

<!-- Pass: aria-label names the toggle -->
<input type="checkbox" role="switch" aria-label="Enable email notifications">

Error

ScanGov messaging when a site fails a standard:

Failed: ARIA toggle fields have accessible names

Guidance

Indicators

On this page