Radio Group
<fieldset class="field-set"> <legend class="field-legend" data-variant="label">Plan</legend>
<div class="radio-group"> <label class="label"> <input class="radio" type="radio" name="plan" value="free" checked /> Free </label> <label class="label"> <input class="radio" type="radio" name="plan" value="pro" /> Pro </label> <label class="label"> <input class="radio" type="radio" name="plan" value="team" /> Team </label> </div></fieldset><div class="radio-group"> <label class="label"> <input class="radio" type="radio" name="plan" value="free" checked /> Free </label> <label class="label"> <input class="radio" type="radio" name="plan" value="pro" /> Pro </label></div>States
Section titled “States”<div class="radio-group"> <label class="label"> <input class="radio" type="radio" name="states" checked /> Checked </label> <label class="label"> <input class="radio" type="radio" name="states" /> Unchecked </label> <label class="label"> <input class="radio" type="radio" name="states-disabled" disabled /> Disabled </label> <label class="label"> <input class="radio" type="radio" name="states-invalid" aria-invalid="true" /> Invalid </label></div>| State | How |
|---|---|
| Checked | the native checked attribute |
| Disabled | the native disabled attribute |
| Invalid | aria-invalid="true" |
Fieldset
Section titled “Fieldset”A radio group needs a name of its own, and <legend> is how you give it one. Without it a screen
reader announces the options but never the question.
<fieldset class="field-set"> <legend class="field-legend" data-variant="label">Plan</legend>
<div class="radio-group"> <label class="label"> <input class="radio" type="radio" name="plan" value="free" checked /> Free </label> <label class="label"> <input class="radio" type="radio" name="plan" value="pro" /> Pro </label> <label class="label"> <input class="radio" type="radio" name="plan" value="team" /> Team </label> </div></fieldset>Keyboard
Section titled “Keyboard”| Key | Action |
|---|---|
| ↑ ↓ ← → | Move to the next or previous option, and select it |
| Tab | Leave the group — the whole group is one tab stop |
All of it comes from the platform, because these are real radio inputs.
Set dir="rtl" on the page or on any subtree — the control moves to the other side of its label on
its own. See the button page for a live example.
Accessibility
Section titled “Accessibility”- One
nameper group. Two groups sharing a name become one group, and only one option across both stays checked. - Wrap the group in a
<fieldset>with a<legend>, rather than a heading. - Do not pre-check an option you do not mean, because the group is then always answered. If the question is genuinely optional, leave every option unchecked and say so.
- Arrow keys select as they move. That is the standard behaviour and it is why a radio group should not trigger anything expensive on change.