View fulldotdev/ui on GitHub

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.

Installation

npx shadcn@latest add @fulldev/radio-group

Usage

import { Label } from "@/components/ui/label"
import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group"
<RadioGroup defaultValue="option-one" name="example">
  <div class="flex items-center gap-3">
    <RadioGroupItem value="option-one" id="option-one" />
    <Label for="option-one">Option One</Label>
  </div>
  <div class="flex items-center gap-3">
    <RadioGroupItem value="option-two" id="option-two" />
    <Label for="option-two">Option Two</Label>
  </div>
</RadioGroup>

RadioGroupItem renders a span with role="radio". Label it with a sibling Label for its id, or by wrapping it in a Label. The group creates a hidden native radio per item, so with name it submits with a form.

Composition

RadioGroup
├── RadioGroupItem
└── RadioGroupItem

Description

Radio group items with a description using the Field component.

Choice Card

Use FieldLabel to wrap the entire Field for a clickable card-style selection.

Fieldset

Use FieldSet and FieldLegend to group radio items with a label and description.

Disabled

Use the disabled prop on RadioGroupItem to disable one item, or on RadioGroup to disable all items.

Invalid

Use aria-invalid on RadioGroupItem and data-invalid on Field to show validation errors.

RTL

API Reference

Source: src/components/ui/radio-group

Behavior comes from @data-slot/radio-group.

RadioGroup

PropTypeDefault
defaultValuestring
namestring
disabledbooleanfalse
readOnlybooleanfalse
requiredbooleanfalse

Listen for radio-group:change ({ value }) on the root, and dispatch radio-group:set with { value } to select a value from a script.

RadioGroupItem

PropTypeDefault
valuestring
disabledbooleanfalse
indicatorClassstring