Skip to content

shadcn.io is not affiliated with official shadcn/ui

Shadcn Radio Group for React

Allows single selection from multiple options.

Installation

bunx --bun shadcn@latest add https://kit.dev/r/aria/radio-group.json

Anatomy

RadioGroup
├── RadioGroupLabel
├── RadioGroupItem
│   ├── RadioGroupText
│   └── RadioGroupItemControl
└── RadioGroupIndicator

Usage

import {
  RadioGroup,
  RadioGroupItem,
} from "@/components/ui/radio-group";
<RadioGroup className="w-fit" defaultValue="comfortable">
  <RadioGroupItem value="default">Default</RadioGroupItem>
  <RadioGroupItem value="comfortable">Comfortable</RadioGroupItem>
  <RadioGroupItem value="compact">Compact</RadioGroupItem>
</RadioGroup>

Accessibility

KeyDescription
Space
Activate the focused control.
End
Go to the end.

Demos

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 RadioGroup to disable all items.

Invalid

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

Rtl

Right-to-left radio group. See the RTL configuration guide for document direction.

API Reference

RadioGroup

PropType
AttributeType

RadioGroupText

PropType
AttributeType

RadioGroupLabel

PropType
AttributeType

RadioGroupItem

PropType
AttributeType