Switch: Reference
Everything you need to re-use the switch.
Requirements
This component fulfils the following requirements:
- The component clearly communicates what is it for.
- The component supports helper text.
- The component supports smart defaults.
- The component supports the following states: on, off, hover (Web only), focused, disabled, pressed and processing
- The transformation between ON and OFF states are enhanced by an animation.
- Toggling the switch (on <-> off) will execute the underlying action immediately.
Keyboard interactions
Key | Action |
---|---|
Enter | On keyboard focus, pressing Enter changes the state of the switch to “On” or “Off”. |
Spacebar | On keyboard focus, pressing Spacebar changes the state of the switch to “On” or “Off”. |
WAI-ARIA roles
Landmarks
- element: "button"
role: "switch"
Screen reader
- name: “Label”
role: switch
state: aria-checked=“true”
SR: “Label, on, switch" - name: “Label”
role: switch
state: aria-checked=“false”
SR: “Label, off, switch”