Radio Group

Use RadioGroup when exactly one option should be selected from a small, visible set.

Preview

Display density

Choose compact, comfortable, or spacious density from three labeled options with supporting descriptions.

Installation

New to this Registry? Complete the base setup before continuing.

npx shadcn@latest add @neumorphism-ui/radio-group

Install the shared base once, then add components and their dependencies with the CLI.

Display density

npx shadcn@latest add @neumorphism-ui/label @neumorphism-ui/radio-group
Registry JSON

Usage

Give the group an accessible name and each RadioGroupItem a unique value and visible label. Set defaultValue or control the selected value with onValueChange.

"use client";

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

export default function Example() {
  const id = useId();
  return (
    <RadioGroup defaultValue="standard" aria-label="Delivery method">
      <Label htmlFor={id + "-standard"} className="flex items-center gap-2">
        <RadioGroupItem id={id + "-standard"} value="standard" />Standard
      </Label>
      <Label htmlFor={id + "-express"} className="flex items-center gap-2">
        <RadioGroupItem id={id + "-express"} value="express" />Express
      </Label>
    </RadioGroup>
  );
}

API Reference

Shares the name and selected state through React context while rendering every item as a real input[type=radio]. Supports controlled and uncontrolled values, horizontal or vertical layout, disabled, and required.

ComponentPropTypeDefaultDescription
RadioGroupvalue / defaultValuestring—The controlled selected value or initial uncontrolled value.
RadioGrouponValueChange(value: string) => void—Called when the selected value changes.
RadioGrouporientation"horizontal" | "vertical""vertical"Sets the layout direction and aria-orientation.
RadioGroupnamestringgenerated idThe native radio name shared by all items.
RadioGroupdisabled / requiredbooleanfalseSets input constraints for all items.
RadioGroupItemvaluerequiredstring—The value passed to the group when the item is selected.

Accessibility

  • 01

    Give the RadioGroup root an accessible group name with aria-label or aria-labelledby.

  • 02

    Connect each RadioGroupItem id to Label htmlFor.

  • 03

    Real radio inputs preserve native form submission and keyboard selection behavior.