Search

Search documentation

Radio Group

A set of checkable buttons—known as radio buttons—where no more than one of the buttons can be checked at a time.

Installation

pnpm dlx shadcn@latest add @evolphin/radio-group

Usage

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

Type Definitions

interface RadioGroupProps {
  /** The value of the selected item */
  value?: string;
RadioGroupProps.value?: string | undefined

The value of the selected item

/** The default value of the selected item when uncontrolled */ ?: string; /** Event handler called when the value changes */ ?: (: string) => void; /** Whether the radio group is disabled */ ?: boolean; }

Examples

Default

API Reference

RadioGroup

PropTypeDefaultDescription
valuestring-The value of the selected item.
defaultValuestring-The default value of the selected item when uncontrolled.
onValueChange(value: string) => void-Event handler called when the value changes.
disabledbooleanfalseWhether the radio group is disabled.
namestring-The name of the radio group.
requiredbooleanfalseWhether the radio group is required.
orientation`"horizontal" \"vertical"`"vertical"
dir`"ltr" \"rtl"`"ltr"
loopbooleantrueWhether to loop through items when navigating.

RadioGroupItem

PropTypeDefaultDescription
valuestring-The value of the item.
disabledbooleanfalseWhether the item is disabled.
requiredbooleanfalseWhether the item is required.

On this page