Skip to content
Logic2BUI

Search docs

Search components and documentation

New
Menu

Radio Group

A set of checkable buttons where no more than one can be checked at a time.

Installation

npx logic2b@next add radio-group

Usage

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 RadioGroupItem with a Label via matching id/htmlFor so 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.

View JSON

RadioGroup

Component
Props: React.ComponentProps<typeof RadioGroupPrimitive.Root>

RadioGroupItem

Component
Props: React.ComponentProps<typeof RadioGroupPrimitive.Item>

Accessibility contract

Machine-readable behavior and consumer responsibilities for radio-group.

View JSON
Support
Primitive-managed
Pattern
radio group
Radix Radio Group
Keyboard interactions for radio-group
KeysBehavior
ArrowUp ArrowDown ArrowLeft ArrowRightMove within the composite control.
SpaceSelect 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.