Radio Cards
Forms
Selection
Selectable card-style radio inputs for choosing between options with rich content.
Preview
Card-based radio selection with icons
Grid Layout
Horizontal card grid for plan selection
Props
Radio Cards component API reference
| Prop | Type | Default | Description |
|---|---|---|---|
options* | RadioCardOption[] | — | Array of selectable options |
value | string | — | Currently selected value (controlled) |
defaultValue | string | — | Default selected value (uncontrolled) |
onChange | (value: string) => void | — | Change handler |
layout | 'vertical' | 'grid' | 'vertical' | Card layout direction |
columns | number | 3 | Grid columns (when layout is grid) |
disabled | boolean | false | Disable all options (options also take their own disabled flag) |
className | string | — | Additional CSS classes |
Usage
Import and implementation example
import { RadioCards } from '@/components/ui/radio-cards'
const options = [ { value: 'card', label: 'Credit Card', description: 'Pay with card', icon: CreditCard }, { value: 'bank', label: 'Bank Transfer', description: 'Direct transfer', icon: Building2 },]
<RadioCards options={options} value={selected} onChange={setSelected} layout="vertical"/>Features
Built-in functionality
- Two layouts: Vertical list or horizontal grid
- Rich content: Icons, descriptions, and pricing in cards
- Selection indicator: Filled check badge, thicker border and tinted background on selection
- Hover, focus and disabled states: Border hover, focus-visible ring and dimmed disabled cards
- Keyboard navigation: Arrow keys to move between options
Accessibility
ARIA support and keyboard navigation
ARIA Attributes
role="radiogroup" on containerrole="radio" on each cardaria-checked for selection stateKeyboard Navigation
| Key | Action |
|---|---|
| Arrow Up/Down | Move between options |
| Space | Select focused option |
| Tab | Move focus in/out of group |
Notes
- Uses radio group pattern for single selection
- Selected state communicated via aria-checked
- Icon decorations are hidden from screen readers