Video examples
iOS Voiceover
Android Talkback
MacOS Voiceover Safari
Code examples
Use semantic HTML
- This semantic HTML contains all accessibility features by default.
- It uses CSS pseudo attributes to create the radio indicator, no Javascript.
Fully disabled radio inputs
Disabled and focusable radio inputs
It’s possible to use aria-disabled="true"
so screen reader users can focus the radio button with the arrow keys. Use preventDefault()
to prevent the checkbox from being checked.
When specific radio inputs are conditionally enabled/disabled by other controls in the page this method can make ensure all radio input options are discoverable.
Required radio inputs
Ensuring all screenreaders indicate radio inputs as being required requires some aria and reinforcement.
- Use
aria-required="true"
to indicate the group is required - Use
aria-invalid="true/false"
to indicate an error state - Add
role="radiogroup"
to the<fieldset>
to make thearia-required
attribute valid - Add “Required” as text to the
<legend>
to ensure compliance across all platforms
Radio button cards
-
Delta (prounounced: dell-tah) is the fourth letter of the NATO alphabet.
-
Echo (prounounced: eck-oh) is the fifth letter of the NATO alphabet.
When you can’t use semantic HTML
This custom button requires extra scripting work for roving tabindex and event listeners.
Specialty use cases
Radio mixed with interactive elements
Avoid placing interactive elements between radio buttons.
- Radio button focus order is not what you think it is.
- When nothing is selected, tab order moves through as expected.
- However, as soon as a radio button is selected, the selected radio input receives focus first from the group.
Checkbox radio hack
- This hack must be used very carefully on a case by case basis.
- With great power comes great responsibility.