Radio Group

A set of checkable buttons, known as radio buttons, where no more than one of the buttons can be checked at a time.

Installation

npx shadcn@latest add @fulldev/radio-group

Usage

---
import { Label } from "@/components/ui/label"
import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group"
---
<RadioGroup defaultValue="option-one" name="example">
  <Label class="gap-3">
    <RadioGroupItem value="option-one" />
    Option One
  </Label>
  <Label class="gap-3">
    <RadioGroupItem value="option-two" />
    Option Two
  </Label>
</RadioGroup>

Label each item by wrapping it in Label. RadioGroupItem renders a span, which Label for cannot point to.

Composition

Use the following composition to build a RadioGroup:

RadioGroup
├── RadioGroupItem
└── RadioGroupItem

Examples

With Descriptions

Radio group items with a title and supporting copy. Wrap the item and its text in Label. A label may only contain phrasing content, so use span elements for the text.

Grid Layout

Wrap the whole row in FieldLabel when you want the entire card to act as the click target. FieldLabel highlights the card when its item is checked.

With FieldSet

Use FieldSet and FieldLegend to group radio items with a shared label and description.

Disabled

Use the disabled prop on RadioGroupItem to disable individual items.

API Reference

See the GitHub source code for more information on props. See the data-slot docs for more information on interactivity.