GitHub
DocsRadio Group

Radio Group

A set of checkable buttons where only one can be checked at a time.

Preview

Installation

npx shadcn@latest add radio-group

Usage

import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group"
import { Label } from "@/components/ui/label"

<RadioGroup defaultValue="option-one">
  <div className="flex items-center space-x-2">
    <RadioGroupItem value="option-one" id="option-one" />
    <Label htmlFor="option-one">Option One</Label>
  </div>
  <div className="flex items-center space-x-2">
    <RadioGroupItem value="option-two" id="option-two" />
    <Label htmlFor="option-two">Option Two</Label>
  </div>
</RadioGroup>

Props

defaultValue — initial selected value (uncontrolled)

value — controlled selected value

onValueChange — callback fired when selection changes

disabled — disables the entire group

orientation — "horizontal" | "vertical" (default)