Radio group
A set of radio buttons for picking exactly one option; a Radio needs a RadioGroup.
import { RadioGroup, Radio } from '@windmorph/react';Keyboard
| Key | Action |
|---|---|
| Tab or Shift + Tab | Moves focus into the group, to the selected option, and out of it in one step. With nothing selected, Tab enters on the first option and Shift + Tab on the last. |
| Arrow Down or Arrow Right | Moves focus to the next option and selects it. |
| Arrow Up or Arrow Left | Moves focus to the previous option and selects it. |
| Space | Selects the focused option, if it is not selected yet. |
- The arrow keys wrap from the last option to the first and back, and skip disabled options.
- In a horizontal group, Arrow Left and Arrow Right follow the laid-out direction, so they are mirrored in right-to-left text, including a
dir="rtl"region of a left-to-right app.
Screen reader
- Role
- The group is a
radiogroup(React AriauseRadioGroup) witharia-orientation. Each option is a visually hidden native<input type="radio">, inside a<label>. - Accessible name
- The group is named by its
label, or byaria-labeloraria-labelledbywithout one. Each option is named by its label (children), or its ownaria-label. - States announced
- Checked or not checked on each option, and disabled, required, invalid (
aria-invalid) and read-only on the group.
- Supporting text is the group's description. While the group is invalid, the error message takes its place below the options and is announced as an alert.
- The drawn ring and dot are hidden from assistive tech; the native inputs carry the state, so forms and labels work as they do natively.
Focus
- The group is one Tab stop, the selected option. Disabled options, and every option of a disabled group, are skipped.
- A read-only group can be focused and moved through, but its selection does not change.
- Keyboard focus shows M3's focus indicator around the focused option's 40px control: a 3px
secondaryoutline 2px outside it, with the focus state layer. Pointer presses show no ring.
Touch target
- Each 20px ring sits in a 40px control with an invisible 48 × 48px touch target. The whole label is part of the target too, since each option is a
<label>. - With
density(or the theme's), each control loses 4px a step, to 28px at -3, and the group keeps its rows 48px apart, top to top, at every density, so the 48 × 48px targets of two options never overlap and each option takes presses over the whole of its target. M3 asks not to apply density by default: offer it as the reader's choice.
Motion
Under reduced motion the dot appears at full size instead of growing in, and the colours still fade. The press ripple appears at full size without growing.
What you need to do
- Name the group with a visible
labelthat asks the question, and give every option a visible label. - Render each
Radioinside aRadioGroup: aRadioon its own throws when it renders. - Use a
RadioGroupfor one choice from a short list; for a longer one use aSelect.