UI.MD

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

API Reference

PropTypeDefaultDescription
defaultValueRadioGroupstring-The value of the item that is checked initially, for uncontrolled usage.
valueRadioGroup, RadioGroupItemstring-On <RadioGroup />, the controlled checked value (use with onValueChange). On <RadioGroupItem />, the value this option submits when checked (required).
onValueChangeRadioGroup(value: string) => void-Called with the newly checked item's value.
nameRadioGroupstring-The 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.
orientationRadioGroup"horizontal" | "vertical"-Axis used for arrow-key navigation between items.
loopRadioGroupbooleantrueWhen true, arrow-key navigation wraps from the last item back to the first.