Skip to content

Slide-toggle should use role="switch" #14949

Closed
@stevenyxu

Description

@stevenyxu

Please describe the feature you would like to request.

mat-slide-toggle should expose an input that causes it to present button and aria-pressed semantics rather than checkbox and aria-checked.

What is the use-case or motivation for this proposal?

The ARIA implementation of mat-checkbox and mat-button-toggle are great. mat-checkbox is a standard checkbox with aria-checked. mat-button-toggle is a standard button with aria-pressed. The usage guidelines are pretty clear: use checkbox when the change is pending form submission and toggle button when the change is effective immediately.

mat-slide-toggle sits in the middle ground in terms of apparent semantics and can plausibly be used in both situations. Currently it only presents as a checkbox. Maybe we could keep this as a default option and add an input that uses button with aria-pressed semantics.

WAI guidelines for toggle buttons: https://www.w3.org/TR/wai-aria-practices/#button

Toggle button: A two-state button that can be either off (not pressed) or on (pressed). To tell assistive technologies that a button is a toggle button, specify a value for the attribute aria-pressed. For example, a button labeled mute in an audio player could indicate that sound is muted by setting the pressed state true. Important: it is critical the label on a toggle does not change when its state changes. In this example, when the pressed state is true, the label remains "Mute" so a screen reader would say something like "Mute toggle button pressed". Alternatively, if the design were to call for the button label to change from "Mute" to "Unmute," the aria-pressed attribute would not be needed.

Is there anything else we should know?

I looked at google3 examples of mat-slide-toggle especially in Cloud Console, and it's pretty split down the middle whether it's a part of a form or effectively a button with immediate action.

Metadata

Metadata

Assignees

Labels

AccessibilityThis issue is related to accessibility (a11y)P4A relatively minor issue that is not relevant to core functions

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions