Component guideEditable source

Radio Group

A labelled set of mutually exclusive choices.

Original component docs
On this page4 sectionsBack to top

Use Radio Group when one choice must be selected from a short visible set. Each item needs a unique value and its own label. Use Select when space is limited or the list is longer.

Live preview
Loading preview...

#Installation

Complete the base setup. For manual installation:

npx shadcn@latest add https://neobrutal-ui.andongmin.com/r/radio-group.json

The preview and Usage example additionally use Label. Install it before copying either example:

npx shadcn@latest add https://neobrutal-ui.andongmin.com/r/label.json

#Usage

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

export default function DeliveryPreference() {
  return (
    <fieldset className="grid gap-3">
      <legend className="mb-3">Delivery frequency</legend>
      <RadioGroup defaultValue="weekly" name="frequency">
        <div className="flex items-center gap-2">
          <RadioGroupItem value="daily" id="daily" />
          <Label htmlFor="daily">Daily</Label>
        </div>
        <div className="flex items-center gap-2">
          <RadioGroupItem value="weekly" id="weekly" />
          <Label htmlFor="weekly">Weekly</Label>
        </div>
      </RadioGroup>
    </fieldset>
  );
}

#API reference

Prop / partPurposeDefault
RadioGroup.value / onValueChangeControlled selectionUncontrolled
RadioGroup.defaultValueInitial choiceUnset
RadioGroup.nameForm submission keyUnset
RadioGroup.disabled / readOnly / requiredGroup constraintsfalse
RadioGroup.form / inputRefNative form association—
RadioGroupItem.value / idUnique option and label targetValue required

#Accessibility

Use a fieldset and legend or an accessible group name. Label each item; its value is not a visible description. Arrow keys change the focused selection. Do not simulate a mutually exclusive choice with independent checkboxes.