Radio group
Picks exactly one of a few options you can see at once.
Usage
pnpm dlx shadcn@latest add radio-groupThen replace components/ui/radio-group.tsx with the Matrix version. It keeps shadcn's API (value, onValueChange, defaultValue) and adds the Matrix sizes and look.
import { RadioGroup, RadioGroupItem } from '@/components/ui/radio-group';
import { Field, FieldLabel } from '@/components/ui/field';
<RadioGroup defaultValue="monthly" aria-label="Billing">
<Field orientation="horizontal">
<RadioGroupItem value="monthly" id="monthly" />
<FieldLabel htmlFor="monthly">Monthly</FieldLabel>
</Field>
<Field orientation="horizontal">
<RadioGroupItem value="yearly" id="yearly" />
<FieldLabel htmlFor="yearly">Yearly</FieldLabel>
</Field>
</RadioGroup>The group handles the rest: one option selected at a time, one tab stop, arrow keys to move.
Variants
States
Focus
Disabled · on
Disabled · off
Invalid
Sizes
sm · 16px, 6px dot (default)
md · 20px, 8px dot
With labels
Which control
| The list is… | Use | Why not the others |
|---|---|---|
| 2–5 visible options, pick one | Radio group | Every option is readable at once, so people compare instead of search. |
| A long or searchable list, pick one | Select or combobox | A radio list you have to scroll stops being comparable. |
| Several independent options | Checkbox | A radio group can never mean "two of these". |
| A setting that applies immediately | Switch | Radios belong to a form that's saved. |
| Inside a dropdown menu | Never a radio | The menu owns the arrow keys; use a menu item with a check. |
Behavior
The group is one tab stop
Tab enters the group once, on the selected option (or the first one). Arrow keys then move and select, skipping disabled options and wrapping at the ends.
Space selects; Enter doesn't
Enter is left for submitting the form.
Give the group a name
Label the group with a FieldLegend inside a FieldSet, or aria-label on RadioGroup, so screen readers announce what the choice is about.
API reference
RadioGroup
Prop
Type
RadioGroupItem
Prop
Type
Guidelines
- Use radios for 2–5 options people should compare at a glance.
- Select a sensible default when one exists, so the group never starts empty without reason.
- Order options logically: most common first, or a natural order (small to large).
- Don't use a single radio on its own; it can't be unselected. Use a checkbox.
- Don't put radios inside a dropdown menu.