Installation
npx logic2b@next add radio-groupUsage
import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group"
<RadioGroup defaultValue="comfortable">
<RadioGroupItem value="default" id="r1" />
<RadioGroupItem value="comfortable" id="r2" />
</RadioGroup>
Examples
Cards
With a disabled option
Accessibility
Built on Radix Radio Group, following the WAI-ARIA radiogroup pattern.
- Arrow keys move between and select options; only one item is checked at a time.
- The group is reachable with Tab; focus lands on the checked item (or the first item if none is selected).
- Pair each
RadioGroupItemwith aLabelvia matchingid/htmlForso the hit target and screen-reader name are correct.
Live playground
Edit the component props and inspect the exact JSX before copying it. The preview loads only when this section enters the viewport.
Generated JSX
<RadioGroup
defaultValue="team"
aria-label="Workspace plan"
>
<label
htmlFor="plan-starter"
className="flex items-center gap-2 text-sm"
>
<RadioGroupItem
id="plan-starter"
value="starter"
/>
<span>Starter</span>
</label>
<label
htmlFor="plan-team"
className="flex items-center gap-2 text-sm"
>
<RadioGroupItem
id="plan-team"
value="team"
/>
<span>Team</span>
</label>
<label
htmlFor="plan-enterprise"
className="flex items-center gap-2 text-sm"
>
<RadioGroupItem
id="plan-enterprise"
value="enterprise"
/>
<span>Enterprise</span>
</label>
</RadioGroup>API reference
Generated from the public TypeScript exports in src/ui/radio-group.tsx.
RadioGroup
ComponentProps: React.ComponentProps<typeof RadioGroupPrimitive.Root>RadioGroupItem
ComponentProps: React.ComponentProps<typeof RadioGroupPrimitive.Item>Accessibility contract
Machine-readable behavior and consumer responsibilities for radio-group.
- Support
- Primitive-managed
- Pattern
- radio group
- Radix Radio Group
| Keys | Behavior |
|---|---|
| ArrowUp ArrowDown ArrowLeft ArrowRight | Move within the composite control. |
| Space | Select the focused option. |
Built-in semantics
- Manages radiogroup/radio roles, aria-checked and roving tab focus.
Consumer responsibilities
- Give the group an accessible name and label every option.