Radio

A set of mutually exclusive options where only one can be selected at a time.

RadioExample

Examples

Disabled

Use the disabled prop on individual radio items to prevent interaction.

RadioDisabledExample

Controlled

Manage the selected value with React state using value and onValueChange on the group.

RadioControlledExample
Selected: system

RadioGroupItem

The RadioGroupItem alias is also available if you prefer that naming convention.

RadioGroupItemExample

Installation

Copy the source code below into your project:

tsx
import { Radio as RadioPrimitive } from "@base-ui/react/radio";
import { RadioGroup as RadioGroupPrimitive } from "@base-ui/react/radio-group";
import { cn } from "@/lib/utils";

function RadioGroup({ className, ...props }: RadioGroupPrimitive.Props) {
  return (
    <RadioGroupPrimitive
      className={cn("flex flex-col gap-3", className)}
      data-slot="radio-group"
      {...props}
    />
  );
}

function Radio({ className, ...props }: RadioPrimitive.Root.Props) {
  return (
    <RadioPrimitive.Root
      className={cn(
        "relative inline-flex size-4 shrink-0 items-center justify-center rounded-full border border-input bg-muted outline-none hover:bg-muted-hover focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive/36 focus-visible:aria-invalid:border-destructive/64 focus-visible:aria-invalid:ring-destructive/48 dark:aria-invalid:ring-destructive/24",
        "data-checked:border-black/10 data-checked:bg-accent",
        className,
      )}
      data-slot="radio"
      {...props}
    >
      <RadioPrimitive.Indicator
        keepMounted
        className={cn(
          "absolute top-1/2 right-1/2 flex size-2 translate-x-1/2 -translate-y-1/2 items-center justify-center rounded-full bg-accent-foreground ring ring-black/5 data-unchecked:hidden",
          "transition-all",
          "data-starting-style:scale-75",
          "data-ending-style:scale-75",
        )}
        data-slot="radio-indicator"
      />
    </RadioPrimitive.Root>
  );
}

export { RadioGroup, Radio, Radio as RadioGroupItem };

API Reference

RadioGroup

This component does not add any props on top of Base UI RadioGroup. See the Base UI docs for the full API reference.

Radio

This component does not add any props on top of Base UI Radio. See the Base UI docs for the full API reference.