Radio Group

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

Basic

Pick one option from a mutually exclusive set.

Installation

CLI
npx @sonojs/ui@latest add radio-group
Also needsnpm i lucide-react

Composition

structure
RadioGroup
├── RadioGroupItem
└── RadioGroupItem

Usage

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

export function Example() {
  return (
    <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>
  )
}

Props

PropTypeDefaultDescription
valuestring—On `RadioGroup` — controlled selected value.
defaultValuestring—On `RadioGroup` — uncontrolled initial value.
onValueChange(value: string) => void—Called when the selected value changes.
disabledbooleanfalseDisable the group or an individual `RadioGroupItem`.
item valuestring—On `RadioGroupItem` — required option value.