Radio Group Example Using Roving tabindex
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 a roving tabindex for managing focus within the radio group.
Similar examples include:
- Radio Group Example Using aria-activedescendant: Radio button group that uses
aria-activedescendant
for managing keyboard focus.
Example
Pizza Crust
Regular crust
Deep dish
Thin crust
Pizza Delivery
Pickup
Home Delivery
Dine in
Accessibility Features
- Uses CSS attribute selectors for synchronizing
aria-checked
state with the visual state indicator. -
Uses CSS
:hover
and:focus
pseudo-selectors for styling visual keyboard focus and hover.- Focus indicator encompasses both radio button and label, making it easier to perceive which option is being chosen.
- Hover changes background of both radio button and label, making it easier to perceive that clicking either the label or button will activate the radio button.
Keyboard Support
Key | Function |
---|---|
Tab |
|
Space |
|
Right arrow |
|
Down arrow |
|
Left arrow |
|
Up arrow |
|
Role, Property, State, and Tabindex Attributes
Role | Attributes | Element | Usage |
---|---|---|---|
radiogroup |
div |
|
|
aria-labelledby="[IDREF]" |
div |
Refers to the element that contains the label of the radio group. | |
radio |
div |
|
|
tabindex="-1" |
div |
|
|
tabindex="0" |
div |
|
|
aria-checked="false" |
div |
|
|
aria-checked="true" |
div |
|
Javascript and CSS Source Code
- CSS: radio.css
- Javascript: radioGroup.js
- Javascript: radioButton.js
HTML Source Code