Demos

Pick one option from a short list.

Usage

Use a radio group when the reader picks exactly one option from a short list, and seeing all options helps them choose. For more than about six options, use a select. For an on and off choice, use a Switch.

Import it from @workspace/ui/components/radio-group.

Anatomy

  • RadioGroup — Holds the selected value. Lays items out in a grid.
  • RadioGroupItem — One option. Wrap it in a label with its text.

Notes

  • Arrow keys move between options. Tab moves out of the group.
  • Name the group with aria-label or a visible heading linked by aria-labelledby.
  • Pick a sensible default when there is one, so the reader does not have to.

Examples

Disabled

Disable a single item, or the whole group with disabled on RadioGroup.

Cards

Wrap each item in a bordered label to make a larger target.

Props

These are the props you set most often. Unlisted props pass through to the underlying element.

RadioGroup

PropTypeDefaultDescription
defaultValueany—Selected value on first render.
valueany—Selected value when controlled.
onValueChange(value) => void—Called when the selection changes.
disabledbooleanfalseDisables every option.
namestring—Field name for form submission.

RadioGroupItem

PropTypeDefaultDescription
valueany—Value of this option.
disabledbooleanfalseDisables this option.