Live example

Cabin
Window or aisle, chosen at check-in
Sold out
Usage
<RadioGroup legend="Status" options={statuses} value={status} onChange={setStatus} orientation="horizontal" />

Props

RadioGroup props
PropTypeDefaultDescription
legendstringnoneGroup label, rendered as the fieldset legend.
optionsRadioOption[]nonevalue, label, optional description and disabled.
value?stringnoneControlled value.
defaultValue?stringnoneUncontrolled initial value.
onChange?(value: string) => voidnoneCalled with the selected value.
orientation?'vertical' | 'horizontal''vertical'Layout of the options.
error?stringnoneError for the whole group.

Do and don't

Do

  • Use for two to six options that benefit from being visible together.
  • Preselect a sensible default when one exists.

Don't

  • Use for long lists; use Combobox.
  • Mix radios and checkboxes in one group.

Accessibility

  • Fieldset and legend name the group.
  • Native radios give the APG keyboard model for free: one Tab stop, arrows move and select.

Keyboard

RadioGroup keyboard support
KeysAction
TabMoves into the group at the checked radio
Arrow keysMove to and select the next or previous radio