fab uifab ui

Radio Group

A set of mutually exclusive options where only one can be selected.

'use client';

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

export function RadioDefault() {
  return (
    <RadioGroup defaultValue='option-1' className='mx-auto w-fit'>
      <div className='flex items-center gap-2'>
        <RadioGroupItem value='option-1' id='option-1' />
        <Label htmlFor='option-1'>Option 1</Label>
      </div>
      <div className='flex items-center gap-2'>
        <RadioGroupItem value='option-2' id='option-2' />
        <Label htmlFor='option-2'>Option 2</Label>
      </div>
      <div className='flex items-center gap-2'>
        <RadioGroupItem value='option-3' id='option-3' />
        <Label htmlFor='option-3'>Option 3</Label>
      </div>
    </RadioGroup>
  );
}

Installation

pnpm dlx shadcn@latest add @fab-ui/radio-group

Usage

import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group"
<RadioGroup defaultValue='option-1'>
  <div className='flex items-center gap-2'>
    <RadioGroupItem value='option-1' id='option-1' />
    <Label htmlFor='option-1'>Option 1</Label>
  </div>
  <div className='flex items-center gap-2'>
    <RadioGroupItem value='option-2' id='option-2' />
    <Label htmlFor='option-2'>Option 2</Label>
  </div>
</RadioGroup>

On this page