On this page
RadioGroup
RadioGroup component for selecting a single option from a list with support for labels, descriptions, and multiple sizes.
import { RadioGroup } from "@ninna-ui/forms";pnpm add @ninna-ui/forms@latestIncludes
@ninna-ui/core. CSS setup required.View source Usage
Import and use the RadioGroup component in your application.
import { RadioGroup, RadioGroupItem } from "@ninna-ui/forms";
export default function Example() { return ( <RadioGroup defaultValue="option1"> <RadioGroupItem value="option1" label="Option 1" /> <RadioGroupItem value="option2" label="Option 2" /> </RadioGroup> );}Basic
Basic radio group with options.
Live preview/ Default
Variants
RadioGroup supports outline, soft, and solid variants.
Live preview/ Default
Outline (default)
Soft
Solid
Sizes
RadioGroup comes in 3 sizes: sm, md, and lg.
Live preview/ Default
Small
Medium
Large
Colors
RadioGroup supports multiple color themes.
Live preview/ Default
Horizontal
RadioGroup with horizontal orientation.
Live preview/ Default
RadioCard
Card-style radio buttons with icons and descriptions.
Live preview/ Default
React Hook Form
RadioGroup works with React Hook Form using the Controller pattern.
Live preview/ Default
API Reference
Complete list of props for RadioGroup and RadioCard components.
RadioGroup Props
| Prop | Type | Default | Description |
|---|---|---|---|
size | 'sm' | 'md' | 'lg' | 'md' | Size of the radio buttons |
color | 'neutral' | 'primary' | 'secondary' | 'accent' | 'info' | 'success' | 'warning' | 'danger' | 'primary' | Color theme of the radio buttons |
variant | 'outline' | 'soft' | 'solid' | 'outline' | Visual variant of the radio buttons |
value | string | — | Controlled value |
defaultValue | string | — | Default value for uncontrolled usage |
onValueChange | (value: string) => void | — | Callback when value changes |
orientation | 'horizontal' | 'vertical' | 'vertical' | Layout orientation |
gap | 'sm' | 'md' | 'lg' | 'md' | Gap between radio items |
invalid | boolean | false | Whether the radio group is in an invalid state |
disabled | boolean | false | Whether the radio group is disabled |
required | boolean | false | Whether a selection is required |
name | string | — | Name for form submission |
loop | boolean | — | Whether to loop keyboard navigation |
aria-label | string | — | Accessible label for the radio group |
aria-labelledby | string | — | ID of the element that labels the radio group |
RadioCard Props
| Prop | Type | Default | Description |
|---|---|---|---|
value | string | — | Value of this radio card (required) |
title | ReactNode | — | Card title |
description | ReactNode | — | Card description text |
icon | ReactNode | — | Icon to display in the card |
disabled | boolean | false | Whether this card is disabled |
aria-label | string | — | Accessible label for the radio card |
aria-describedby | string | — | ID of element that describes this radio card |
Accessibility
- Built on Radix UI RadioGroup for full
WAI-ARIAcompliance - Uses
role="radiogroup"announced to screen readers - Supports
aria-labelandaria-labelledbyfor labeling - Keyboard navigation: Arrow keys to navigate, Space to select
- Labels are properly associated with radio buttons
- Proper focus states with visible outlines