Skip to content

Radio Group

A single-choice set of radio buttons for plans, shipping options, and settings forms — with the neobrutalist borders-and-shadows treatment.

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

The radio group presents a set of mutually exclusive options — checking one item unchecks the rest. Built on the Base UI Radio Group component and styled to the neobrutalist recipe: thick borders, hard shadows, and bold type.

Reach for it when:

  • Plan pickers — free / pro / enterprise as choice cards, one selection enforced.
  • Checkout options — shipping speed or payment method, where every choice must stay visible.
  • Settings with 2–5 options — theme, density, notification frequency; fewer clicks than a select.

Installation

pnpm dlx shadcn@latest add https://neobrutalism.com/r/base/radio-group.json
npx shadcn@latest add https://neobrutalism.com/r/base/radio-group.json
yarn dlx shadcn@latest add https://neobrutalism.com/r/base/radio-group.json
bunx --bun shadcn@latest add https://neobrutalism.com/r/base/radio-group.json

Install the following dependencies:

pnpm add @base-ui/react
npm install @base-ui/react
yarn add @base-ui/react
bun add @base-ui/react

Copy and paste the following code into your project.

components/ui/radio-group.tsx
"use client"

import * as React from "react"
import { RadioGroup as RadioGroupPrimitive } from "radix-ui"

import { cn } from "@/lib/utils"

function RadioGroup({
  className,
  ...props
}: React.ComponentProps<typeof RadioGroupPrimitive.Root>) {
  return (
    <RadioGroupPrimitive.Root
      data-slot="radio-group"
      className={cn("grid w-full gap-2", className)}
      {...props}
    />
  )
}

function RadioGroupItem({
  className,
  ...props
}: React.ComponentProps<typeof RadioGroupPrimitive.Item>) {
  return (
    <RadioGroupPrimitive.Item
      data-slot="radio-group-item"
      className={cn(
        "group/radio-group-item peer relative flex aspect-square size-5 shrink-0 rounded-full border-2 bg-input shadow-sm outline-none after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive",
        className
      )}
      {...props}
    >
      <RadioGroupPrimitive.Indicator
        data-slot="radio-group-indicator"
        className="flex size-4 items-center justify-center"
      >
        <span className="absolute top-1/2 left-1/2 size-2 -translate-x-1/2 -translate-y-1/2 rounded-full bg-primary" />
      </RadioGroupPrimitive.Indicator>
    </RadioGroupPrimitive.Item>
  )
}

export { RadioGroup, RadioGroupItem }

Update the import paths to match your project setup.

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>

Composition

Use the following composition to build a RadioGroup:

RadioGroup
├── RadioGroupItem
└── RadioGroupItem

Examples

Description

Radio group items with a description using the Field component.

import {
  Field,
  FieldContent,

Choice Card

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

import {
  Field,
  FieldContent,

Fieldset

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

import {
  Field,
  FieldDescription,

Disabled

Use the disabled prop on RadioGroup to disable all items.

import { Field, FieldLabel } from "@/components/ui/field"
import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group"

Invalid

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

import {
  Field,
  FieldDescription,

RTL

To enable RTL support in Neobrutalism.com, see the RTL configuration guide.

"use client"

import * as React from "react"

Accessibility

The radio group follows the WAI-ARIA Radio Group pattern: the container renders role="radiogroup", each item is a role="radio" button with aria-checked, and roving tabindex keeps the whole group a single tab stop.

Keyboard interactions:

KeyAction
Tab / Shift + TabMove focus into the group (checked item, or first item) / out
SpaceCheck the focused item if it isn't already
ArrowDown / ArrowRightMove focus to the next item and check it
ArrowUp / ArrowLeftMove focus to the previous item and check it

Left and right arrows follow the reading direction in RTL.

API Reference

See the Base UI Radio Group documentation.