Use Radio Button...
- To prompt users to choose from a set of mutually-exclusive choices.
- Inside a Selection Set as
variant="single-select".
Don't use Radio Button...
- To select more than one option. Use Checkbox instead.
- To prompt users to choose between two mutually exclusive options that always has a default value, like “On” or “Off”. Use Toggle Switch instead.
The preview has been updated.
Disabled
Use disabled to prevent users from selecting the Radio Button; when an option is unchangeable and not part of the current task.
The preview has been updated.
Accessibility
Radio Button wrapping
Use RadioButton within a Selection Set.
Alternatively, if you wish to have more control over your layout, either:
- Use Fieldset to place the radio buttons inside.
The preview has been updated.
- Or use an element that has both
role="radiogroup"and the mandatoryaria-labelledbyattribute. The value ofaria-labelledbyshould be theidof the element serving as the title for the radio group. If the group lacks a visible title, use thearia-labelattribute with a descriptive title for the radio group. Ensure the value ofaria-labelis localized, since some browsers read it aloud to the user.
The preview has been updated.
Required field
When a radio button is required for form submission:
- Use
aria-required="true"on the Radio Buttons' wrapper (it tells AT that this form input is required). - Also, use
requiredon all of the Radio Buttons in the wrapped group (it tells the browser to block form submission until one of them is selected).