Radio Group

A set of checkable buttons where only one can be selected at a time.

Installation

$
npx shadcn@latest add https://ui.mattdowney.com/r/radio-group.json

Usage

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

Examples

Default

One choice from a short list. Arrow keys move between the options, so the whole group is a single tab stop rather than one per item.

API Reference

PropTypeDefaultDescription
defaultValueRadioGroupstringNoneThe value of the item that is checked initially, for uncontrolled usage.
valueRadioGroup, RadioGroupItemstringNoneOn <RadioGroup />, the controlled checked value (use with onValueChange). On <RadioGroupItem />, the value this option submits when checked (required).
onValueChangeRadioGroup(value: string) => voidNoneCalled with the newly checked item's value.
nameRadioGroupstringNoneThe name submitted with form data.
disabledRadioGroup, RadioGroupItembooleanfalseDisables every item, or a single option on <RadioGroupItem />.
requiredRadioGroupbooleanfalseRequires a selection before the owning form can be submitted.
defaultValueRadioGroupstringThe value of the item that is checked initially, for uncontrolled usage.
valueRadioGroup, RadioGroupItemstringOn <RadioGroup />, the controlled checked value (use with onValueChange). On <RadioGroupItem />, the value this option submits when checked (required).
onValueChangeRadioGroup(value: string) => voidCalled with the newly checked item's value.
nameRadioGroupstringThe name submitted with form data.
disabledRadioGroup, RadioGroupItemboolean = falseDisables every item, or a single option on <RadioGroupItem />.
requiredRadioGroupboolean = falseRequires a selection before the owning form can be submitted.