shadcn.io is not affiliated with official shadcn/ui
Radio Group examples · Standard
Basic Radio Group for React
A vertical radio group of three options, the first one selected, for a single choice in a form or settings page.
The plainest single choice: three options stacked, one checked, and picking another clears it. Each option's text is its label, so clicking the words checks the radio. In React, Base UI handles the arrow keys and the checked state. Use it for a preference, a survey question, or any short list where exactly one answer counts.
Preview
Installation
FAQ
How does Option 1 start selected?
RadioGroup sets defaultValue to option-1, which matches the first item's value. Leave defaultValue off when nothing should start checked.
How do I control the selected value?
This demo uses defaultValue, so the group stores the choice. Pass value, and onValueChange receives the next string.
Why does clicking Option 2 check the radio?
The text is the item's label, so clicking it checks that item. Each RadioGroupItem has an id, and FieldLabel points at it with htmlFor.
How do I change the space between options?
RadioGroup lays the options out in a grid with a gap from the style. Pass a gap-* class on RadioGroup when you want more or less space.
Related
- Radio Group with DescriptionsA radio group with a line of muted text
- Horizontal Radio GroupA radio group with its three options in a
- Radio Group with CardsPlan options as bordered cards, where
- Radio Group in FormA required notification setting in a form
- Radio Group with IconsPayment method options with an icon
- Simple CheckboxA checkbox with a label for a single