Radio Group
A set of checkable buttons where only one can be checked at a time.
Installation
npx shadcn@latest add https://reactdocs.canceydejean.dev/r/radio-group.jsonUsage
Use for mutually exclusive choices. Pair each RadioGroupItem with a label.
import { Label } from "@/components/label/label";
import {
RadioGroup,
RadioGroupItem,
} from "@/components/radio-group/radio-group";
export function Example() {
return (
<RadioGroup defaultValue="comfortable">
<div className="flex items-center gap-2">
<RadioGroupItem value="default" id="r1" />
<Label htmlFor="r1">Default</Label>
</div>
<div className="flex items-center gap-2">
<RadioGroupItem value="comfortable" id="r2" />
<Label htmlFor="r2">Comfortable</Label>
</div>
<div className="flex items-center gap-2">
<RadioGroupItem value="compact" id="r3" />
<Label htmlFor="r3">Compact</Label>
</div>
</RadioGroup>
);
}Control with value / onValueChange, or use defaultValue for uncontrolled groups.