Radio
A radio group component with standard and card variants, built on Radix UI for full accessibility.
Overview
The RadioGroup component is used for selecting a single option from a set. It supports standard radio buttons, a card variant for richer selection UIs, descriptions, two sizes, horizontal/vertical orientation, and disabled states.
Installation
Install the component via the CLI in one command.
npx @work-rjkashyap/unified-ui add radiopnpm dlx @work-rjkashyap/unified-ui add radionpx @work-rjkashyap/unified-ui add radiobunx @work-rjkashyap/unified-ui add radioIf you haven't initialized your project yet, run npx @work-rjkashyap/unified-ui init first. See the CLI docs for details.
Or install the full package
Use this approach if you prefer to install the entire design system as a dependency instead of copying individual components.
npm install @work-rjkashyap/unified-uipnpm add @work-rjkashyap/unified-uiyarn add @work-rjkashyap/unified-uibun add @work-rjkashyap/unified-uiAnatomy
import {
RadioGroup,
RadioGroupItem,
RadioCard,
} from "@work-rjkashyap/unified-ui";Examples
Basic Usage
Sizes
With Descriptions
Horizontal Orientation
Radio Card Variant
Disabled State
Combined Features
Props
RadioGroup
| Prop | Type | Default | Description |
|---|---|---|---|
value | string | — | Controlled selected value. |
defaultValue | string | — | Initial selected value (uncontrolled). |
onValueChange | (value: string) => void | — | Callback when the selection changes. |
size | "sm" | "md" | "md" | Size of all radio items in the group. |
orientation | "vertical" | "horizontal" | "vertical" | Layout direction of items. |
disabled | boolean | false | Disables all items in the group. |
className | string | — | Additional CSS classes. |
RadioGroupItem
| Prop | Type | Default | Description |
|---|---|---|---|
value | string | Required | The value of this radio item. |
label | ReactNode | — | Clickable label text. |
description | ReactNode | — | Additional description below the label. |
disabled | boolean | false | Disables this individual item. |
className | string | — | Additional CSS classes. |
RadioCard
| Prop | Type | Default | Description |
|---|---|---|---|
value | string | Required | The value of this radio card. |
label | ReactNode | — | Card title / label text. |
description | ReactNode | — | Description text below the label. |
disabled | boolean | false | Disables this card. |
className | string | — | Additional CSS classes. |
Accessibility
Built on Radix UI's Radio Group primitive for full keyboard and screen reader support out of the box.
- Arrow keys navigate between items within the group.
- Space selects the focused item.
- Each item has proper
role="radio"andaria-checkedattributes. - Labels are associated with their radio inputs for click-to-select behavior.
- Focus ring is visible on keyboard navigation only (
focus-visible). - Disabled items are excluded from the tab order and marked with
aria-disabled.
Design Tokens
The Radio components use the following design system tokens:
| Token | Usage |
|---|---|
--primary | Selected indicator color |
--primary-foreground | Selected indicator dot |
--border | Default border color |
--muted-foreground | Description text color |
--radius-full | Radio circle border radius |
--radius-md | RadioCard border radius |
--duration-fast | Transition speed |