apps/v4/content/docs/components/base/radio-group.mdx
npx shadcn@latest add radio-group
<Step>Install the following dependencies:</Step>
npm install @base-ui/react
<Step>Copy and paste the following code into your project.</Step>
<ComponentSource name="radio-group" title="components/ui/radio-group.tsx" styleName="base-nova" />
<Step>Update the import paths to match your project setup.</Step>
</Steps> </TabsContent> </CodeTabs>import { Label } from "@/components/ui/label"
import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group"
<RadioGroup defaultValue="option-one">
<div className="flex items-center gap-3">
<RadioGroupItem value="option-one" id="option-one" />
<Label htmlFor="option-one">Option One</Label>
</div>
<div className="flex items-center gap-3">
<RadioGroupItem value="option-two" id="option-two" />
<Label htmlFor="option-two">Option Two</Label>
</div>
</RadioGroup>
Radio group items with a description using the Field component.
Use FieldLabel to wrap the entire Field for a clickable card-style selection.
Use FieldSet and FieldLegend to group radio items with a label and description.
Use the disabled prop on RadioGroup to disable all items.
Use aria-invalid on RadioGroupItem and data-invalid on Field to show validation errors.
To enable RTL support in shadcn/ui, see the RTL configuration guide.
<ComponentPreview styleName="base-nova" name="radio-group-rtl" direction="rtl" />
See the Base UI Radio Group documentation.