Radio group
Selects exactly one option from a short list, shown as radio dots or as bordered buttons.
orientation
<RadioGroup />RadioGroup owns the selected value and the keyboard navigation.
RadioGroupItem is one option. The item has no label of its own: place a
Label next to it, or use variant="button" and put the text in the item.
When to use
- To pick exactly one option from two to six, where seeing all of them helps the decision.
- For a choice sent with a form, such as the reason to skip a task or the export format.
When not to use
- More than six options. Use Select.
- Options that need a title and a description. Use Radio card.
- Picking several options. Use Checkbox.
- A binary setting. Use Switch or Checkbox.
- A filter that the user can clear. Use Radio filter.
Variants
Button
variant="button" draws each item as a bordered button with the label inside.
The selected one gets a brand border. Pass indicator to replace the default
dot.
| Variant | Use for |
|---|---|
default |
A form. A 16px radio next to a Label. |
button |
A short list of choices that should be easy to hit, such as formats. |
States
Enabled, disabled and horizontal groups.
Content
- Label every option with a noun phrase: “Documento ilegível”.
- Keep options mutually exclusive and complete. Add “Outro” when needed.
- Preselect an option only when there is a safe default.
Do and don’t
PDF
Word (.docx)
Accessibility
- Built on Radix Radio Group: the group has
role="radiogroup"and each item hasrole="radio"witharia-checked. Tabenters the group at the selected item, or at the first one when none is selected. Arrow keys move focus and selection, skip disabled items and wrap at the ends.Spaceselects the focused item.- Name the group with
aria-labeloraria-labelledby, or wrap it in afieldsetwith alegend. - With
variant="button", the item text is its accessible name. In the default variant, link aLabelwithhtmlForand the itemid. - The focus ring appears only for keyboard focus (
focus-visible).
Code
import { Label } from "@repo/ui/label";
import { RadioGroup, RadioGroupItem } from "@repo/ui/radio-group";
<RadioGroup
aria-label="Motivo para pular a tarefa"
onValueChange={setReason}
value={reason}
>
<div className="flex items-center gap-2">
<RadioGroupItem id="ilegivel" value="ilegivel" />
<Label htmlFor="ilegivel">Documento ilegível</Label>
</div>
</RadioGroup>;
Props
RadioGroup| Prop | Type | Default | Description |
|---|---|---|---|
disabled | boolean | false | Disables every item in the group |
onValueChange | (value: string) => void | — | Called with the value of the newly selected item |
orientation | "horizontal" | "vertical" | undefined | Direction of arrow-key navigation |
required | boolean | false | Marks the group as required for forms and assistive tech |
value | string | — | Controlled value of the selected item |
RadioGroupItem| Prop | Type | Default | Description |
|---|---|---|---|
value | string | — | Unique value of the item. Required. |
variant | "default" | "button" | "default" | Radio dot, or a bordered button with the label inside. |
indicator | ReactNode | — | Replaces the default selected indicator. |
indicatorClassName | string | — | Extra class for the indicator wrapper. |
disabled | boolean | false | Disables this item. The group can also disable all items. |
Known issues
| Issue | Effect |
|---|---|
The default item is h-4 w-4 (16px) and its disabled style is disabled:opacity-50. |
Below the 24px hit target, and a translucent disabled state. |
| The default variant has no label slot. | Each app builds its own label layout, so spacing and click targets vary. |
The focus ring uses ring-offset-background. The Tailwind config only defines old-background. |
The class generates nothing. The offset falls back to Tailwind’s default, white. |
No style for aria-invalid. |
A group cannot show a validation error. |