Radio Group
A set of options where only one can be chosen. The circle is 24px with an invisible 44px hit area, and items sit 44px apart.
Installation
npx shadcn@latest add @sevenone/radio-groupUsage
import { Label } from "@/components/ui/label"
import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group"Examples
Default
<RadioGroup defaultValue="comfortable" aria-label="Density">
<div className="flex items-center gap-3.5">
<RadioGroupItem value="default" id="r1" />
<Label htmlFor="r1">Default</Label>
</div>
<div className="flex items-center gap-3.5">
<RadioGroupItem value="comfortable" id="r2" />
<Label htmlFor="r2">Comfortable</Label>
</div>
…
</RadioGroup>With descriptions
Pay with a credit or debit card.
Pay instantly with a QR code.
Get an invoice and pay within 30 days.
<div className="flex items-start gap-3.5">
<RadioGroupItem value="card" id="card" aria-describedby="card-desc" />
<div className="grid gap-1.5">
<Label htmlFor="card">Card</Label>
<p id="card-desc" className="text-sm text-muted-foreground">
Pay with a credit or debit card.
</p>
</div>
</div>Accessibility
- Give the group a name with aria-label or a visible legend, and give every item a Label.
- Arrow keys move between options; Tab moves in and out of the group.
- The hit areas are 44px and never overlap, so options are easy to tap.