Radio Group
Native radios in a fieldset with a legend: browser arrow keys and form submit, a dot that springs in, optional per-option descriptions, vertical or horizontal.
import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group";export function PlanPicker() { return ( <RadioGroup legend="Plan" name="plan" defaultValue="pro"> <RadioGroupItem value="free" description="1 server, 50 clips a month."> Free </RadioGroupItem> <RadioGroupItem value="pro" description="10 servers, unlimited clips."> Pro </RadioGroupItem> </RadioGroup> );}<RadioGroup>
Native radios in a fieldset: arrow keys, form submit and labels work as the browser does.
aria-invalidbooleanIndicates the entered value does not conform to the format expected by the application.
defaultValuedefault""stringValue at first render (uncontrolled).
legendReactNodeVisible group label, rendered as the fieldset's <legend>.
namestringForm field name; generated when omitted.
onValueChange(value: string) => voidCalled with the picked item's value.
orientationdefault"vertical""vertical" | "horizontal"Stack items or lay them in a row.
valuestringControlled value; pair with
onValueChange.
| Prop | Type | Default |
|---|---|---|
aria-invalidIndicates the entered value does not conform to the format expected by the application. | boolean | — |
defaultValueValue at first render (uncontrolled). | string | "" |
legendVisible group label, rendered as the fieldset's <legend>. | ReactNode | — |
nameForm field name; generated when omitted. | string | — |
onValueChangeCalled with the picked item's value. | (value: string) => void | — |
orientationStack items or lay them in a row. | "vertical" | "horizontal" | "vertical" |
valueControlled value; pair with | string | — |
Also accepts every <fieldset> prop.
<RadioGroupItem>
One option. children is its label; description adds a muted line under it.
children*ReactNodeLabel.
value*stringSubmitted value.
descriptionReactNodeMuted line under the label.
disabledbooleanShown but not selectable.
| Prop | Type | Default |
|---|---|---|
children*Label. | ReactNode | — |
value*Submitted value. | string | — |
descriptionMuted line under the label. | ReactNode | — |
disabledShown but not selectable. | boolean | — |
* required. Every component also takes className.