ARIA radiogroup
and radio
Example
Authoring Practice Design Patten for Radio Group
- The
radiogroup
role defines a container for a set of ARIA radio buttons. - The radio button that is currently checked is identified using
aria-checked=“true”.
- Only one radio button can be selected at a time, all other radio buttons should define
aria-checked
as “false". - The label for the radio group is defined using
aria-labelledby
attribute. (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”…)
Radio Example
Pizza Crust
Regular crust
Deep dish
Thin crust
Accessibility Feature
div
element with roleradio
hasonkeydown
event to support keyboard activation of the radio.div
element with roleradio
hastabindex="0"
to become part of the tab order of the page.- Each radio has
tabindex="-1"
except one. - CSS Generated Content 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; the visuals are created in CSS rather than via the use of a background image. (Note: CSS background image techniques result in visual state disappearing when browsers or operating systems are configured to display high contrast themes.)
setRadioButton
function usesaria-checked
attribute to make sure the information communicated to asssitive tecnology is the same as the visual state. (e.g.img
element)onfocus
andonblur
event handlers onradio
support visual focus styling for keyboard only users.
Keyboard Support
Key | Function |
---|---|
Tab | Moves keyboard focus to radiogroup. |
Arrow | Moves up and down radio options. |
ARIA Roles, Properties and States
Role | Property/State | Usage |
---|---|---|
Radiogroup |
|
|
Radio | aria-checked |
|
aria-labelledby |
|
Source Code
<div role="radiogroup"
aria-labelledby="gdesc1"
>
<h3>
Pizza Crust
</h3>
<div role="radio"
aria-checked="false"
tabindex="0">
Regular crust
</div>
<div role="radio"
aria-checked="false"
tabindex="-1">
Deep dish
</div>
<div role="radio"
aria-checked="false"
tabindex="-1">
Thin crust
</div>
</div>