Make your AI a shadcn expert

Shadcn Radio Group

React radio group for checkout, surveys, and settings. Built with TypeScript and Tailwind CSS for Next.js using Base UI — one option selected, arrow keys move.

A radio group is one answer from a short list. Click a row and the others clear. Use it for shipping speed, a plan, or a survey — anything where picking two would be a bug.

Scroll to load preview...

Looking for a neobrutalism version for shadcn?

Same radio group, thicker borders. The NeoBrutalism radio group is the kit if you want that look.

Usage

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

defaultValue is the one that starts checked. Own the state with value and onValueChange.

Composition

RadioGroupItem
RadioGroupItem

Pair each item with a Label or Field. The indicator lives inside RadioGroupItem.

Description

FieldContent plus FieldDescription for the helper line under the label.

Scroll to load preview...

Choice Card

Wrap the Field in FieldLabel so the whole card is the click target.

Scroll to load preview...

Fieldset

FieldSet plus FieldLegend name the group. That's the markup a screen reader expects.

Scroll to load preview...

Disabled

disabled on RadioGroupItem, data-disabled on the Field so the label greys out with it.

Scroll to load preview...

Invalid

aria-invalid on the item. data-invalid on the Field. Both, or the label stays the wrong color.

Scroll to load preview...

RTL

Wrap with DirectionProvider and dir="rtl". Labels stay Arabic.

Scroll to load preview...

API

Prop

Type

RadioGroupItem

Prop

Type

Keyboard

KeyAction
TabFocus the checked item, or the first if none
SpaceCheck the focused item if it isn't already
ArrowDown / ArrowRightMove to the next item and check it
ArrowUp / ArrowLeftMove to the previous item and check it

Notes

Arrows select, they don't just move

ArrowDown checks the next item. There is no focused-but-unchecked state. Don't put a dummy first value if you don't want it posted.

orientation is for the arrow keys. Layout is still grid gap-3 — stack or row it yourself.

With other components

Questions

Was this page helpful?

Sign in to leave feedback.