switch role
The ARIA role for an on/off control whose change takes effect immediately, like a light switch.
In more detail
A switch is usually a <button type="button" role="switch"> with aria-checked, toggled by click, Space or Enter. Screen readers announce it as on or off rather than checked or unchecked.
Related terms
- aria-checked — An ARIA state giving the checked state of a checkbox, radio button or switch: true, false or, for checkboxes, mixed.
- checkbox — A form control that can be checked or unchecked, usually submitted with a form.
- button type — The type attribute of an HTML button: submit (the default inside a form), button (does nothing by itself) or reset.
Taught in
- Headless Architecture: State vs Presentation Separation — Design Systems & Component Engineering
- Actionable Form Primitives: Buttons, Switches & Inputs — Design Systems & Component Engineering