Docs
Radio Group

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.

This component uses Radix UI
import { Label_Shadcn_ } from 'ui'
import { RadioGroup_Shadcn_, RadioGroupItem_Shadcn_ } from 'ui'
 
export function RadioGroupDemo() {
  return (
    <RadioGroup_Shadcn_ defaultValue="comfortable">
      <div className="flex items-center space-x-2">
        <RadioGroupItem_Shadcn_ value="default" id="r1" />
        <Label_Shadcn_ htmlFor="r1">Default</Label_Shadcn_>
      </div>
      <div className="flex items-center space-x-2">
        <RadioGroupItem_Shadcn_ value="comfortable" id="r2" />
        <Label_Shadcn_ htmlFor="r2">Comfortable</Label_Shadcn_>
      </div>
      <div className="flex items-center space-x-2">
        <RadioGroupItem_Shadcn_ value="compact" id="r3" />
        <Label_Shadcn_ htmlFor="r3">Compact</Label_Shadcn_>
      </div>
    </RadioGroup_Shadcn_>
  )
}

Installation

npx shadcn-ui@latest add radio-group

Usage

import { Label } from '@/components/ui/label'
import { RadioGroup, RadioGroupItem } from '@/components/ui/radio-group'
<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>

Examples

Form