Radio Group Example Using aria-activedescendant
This example implements the features of the Radio Group Design Pattern
for two radio groups -- one for choosing a pizza crust and another for choosing a delivery method.
This implementation uses aria-activedescendant for informing assistive technologies which radio button has visual focus.
Similar examples include:
- Radio Group Example Using Roving tabindex: A radio button group that uses roving
tabindexfor managing keyboard focus.
Example
Pizza Crust
- Regular crust
- Deep dish
- Thin crust
Pizza Delivery
- Pick up
- Home Delivery
- Dine in Restaurant
Accessibility Features
- Uses CSS attribute selectors for synchronizing
aria-checkedstate with the visual state indicator. - Uses CSS
:hoverpseudo selector for visual hover styling. - Uses CSS
.focusclass for visual keyboard focus styling.
Keyboard Support
NOTE: When visual focus is on a radio button in the radio group, DOM focus remains on the radio group container and the value of aria-activedescendant on the radio group refers to the radio button that is visually indicated as focused.
Where the following descriptions of keyboard commands mention focus, they are referring to the visual focus indicator, not DOM focus.
For more information about this focus management technique, see
Using aria-activedescendant to Manage Focus.
| Key | Function |
|---|---|
| Tab |
|
| Space |
|
| Right arrow |
|
| Down arrow |
|
| Left arrow |
|
| Up arrow |
|
Role, Property, State, and Tabindex Attributes
| Role | Attributes | Element | Usage |
|---|---|---|---|
radiogroup |
div |
Identifies the div element as a container for a group of radio buttons. |
|
aria-labelledby="[IDREF]" |
div |
Refers to the element that contains the label of the radio group. | |
tabindex="0" |
ul |
|
|
aria-activedescendant="[IDREF]" |
ul |
|
|
radio |
div |
|
|
aria-checked="false" |
div |
|
|
aria-checked="true" |
div |
|
Javascript and CSS Source Code
- CSS: radio.css
- Javascript: radioGroupActiveDescendant.js
- Javascript: radioButtonActiveDescendant.js
HTML Source Code