ARIA radiogroup Example
Authoring Practice Design Patten for Radio group
- The
radiogrouprole defines a container for a set of ARIA radio buttons. - The radio button that is currently selected is identified using
aria-checked=“true” - Only one radio button can be selected at a time, all other radio buttons should define
aria-checkedas “false". - The label for the radio group is defined using
aria-labelledbyattribute (e.g. “Pizza Crust”) - The labels for the radio buttons are defined by the text nodes of each radio button (e.g. “Regular Crust”, “Deep Dish”…)
- test2
Pizza Crust
Regular crust
Deep dish
Thin crust
Accessibility Feature
divelement with roleradiohasonkeydownevent to support keyboard activation of the radio.divelement with roleradiohastabindex="0"to become part of the tab order of the page.imgelement is used to visually indicate the state of radio (e.g. checked,unchecked) to ensure the visual state will be visible when browsers or operating system use “High Contrast” settings by people with visual impairments. (Note: CSS background image techniques or generated content result in visual state disappearing when browsers or operating systems are configured to display high contrast themes.)setRadioButtonfunction usesaria-checkedattribute to make sure the information communicated to asssitive tecnology is the same as the visual state (e.g.imgelement).onfocusandonblurevent handlers onradiosupport visual focus styling for keyboard only users.
Keyboard Support
| Key | Function |
|---|---|
| Tab | Moves keyboard focus to radiogroup. |
| Up and Down arrow | Moves up and down radio options. |
ARIA Roles, Properties and States
| Role | Property/State | Usage |
|---|---|---|
| Radiogroup |
|
|
| Radiogroup | aria-labelledby |
|
| Radio | aria-checked |
|
Source Code
- CSS: radio-1.css
- Javascript: radio-1.js