Skip to main content
Tw Twintrinsic
  • Getting Started
  • Components
  • Theming
  • Completion
Examples
Data Dashboard Game Map
Core
App
Layout
Accordion AccordionItem Card Container Panel Separator Sidebar Splitter
Navigation
AppHeader BottomBar Breadcrumb BreadcrumbItem Menu MenuItem Tabs Tab TabList TabPanel TreeMenu
Data Display
Avatar AvatarGroup Badge Carousel CarouselItem Chip ChipGroup CodeBlock CodeBlockSpeed CodeEditor DataTable Map Progress Skeleton Table TableBody TableCell TableHead TableHeader TableRow Tag TagGroup Timeline TimelineItem Tooltip Tree TreeNode
Metrics
DonutChart PieChart LineChart BarChart HorizontalBarChart AreaChart StatsCard MetricGrid KPICard GaugeChart ProgressMetric MetricTrend
Form
AutoComplete Button ButtonGroup Calendar Checkbox ColorPicker Combobox Dropdown FileUpload FloatLabel Form FormField Input InputSwitch InvalidState Knob ListInput Listbox NumberInput Radio RadioGroup Rating Select SelectGroup Slider Switch TextInput Textarea
Feedback
Modal Stepper StepperStep Toast
Utility
Icon Lazy LazyPanel Masonry ThemeToggle

RadioGroup

The RadioGroup component provides a way to group related radio buttons with consistent styling, accessibility features, and form integration. It supports both horizontal and vertical layouts, different sizes, and integrates seamlessly with the Form component.

Examples

Basic Usage

Select theme
<RadioGroup name="theme" legend="Select theme">
  <Radio value="light" label="Light" />
  <Radio value="dark" label="Dark" />
  <Radio value="system" label="System" />
</RadioGroup>

Horizontal Layout

Text alignment
<RadioGroup name="alignment" legend="Text alignment" layout="horizontal">
  <Radio value="left" label="Left" />
  <Radio value="center" label="Center" />
  <Radio value="right" label="Right" />
</RadioGroup>

With Initial Value

Size
<RadioGroup name="size" legend="Size" value="md">
  <Radio value="sm" label="Small" />
  <Radio value="md" label="Medium" />
  <Radio value="lg" label="Large" />
</RadioGroup>

Different Sizes

Small
Medium
Large
<RadioGroup name="size-sm" legend="Small" size="sm" layout="horizontal">
  <Radio value="1" label="Option 1" />
  <Radio value="2" label="Option 2" />
  <Radio value="3" label="Option 3" />
</RadioGroup>

<RadioGroup name="size-md" legend="Medium" size="md" layout="horizontal">
  <Radio value="1" label="Option 1" />
  <Radio value="2" label="Option 2" />
  <Radio value="3" label="Option 3" />
</RadioGroup>

<RadioGroup name="size-lg" legend="Large" size="lg" layout="horizontal">
  <Radio value="1" label="Option 1" />
  <Radio value="2" label="Option 2" />
  <Radio value="3" label="Option 3" />
</RadioGroup>

Disabled State

Unavailable options
<RadioGroup name="disabled-group" legend="Unavailable options" disabled={true}>
  <Radio value="1" label="Option 1" />
  <Radio value="2" label="Option 2" />
  <Radio value="3" label="Option 3" />
</RadioGroup>

Props

PropTypeDefaultDescription
namestringRequiredName attribute for the radio group
valuestring''Currently selected value
legendstringRequiredLegend text for the fieldset
requiredbooleanfalseWhether the radio group is required
disabledbooleanfalseWhether the radio group is disabled
layout'vertical' | 'horizontal''vertical'Layout direction of radio buttons
size'sm' | 'md' | 'lg''md'Size of the radio buttons
idstringauto-generatedHTML id for accessibility
classstring''Additional CSS classes

Events

EventDetail TypeDescription
onchange{ value: string }Fired when a radio button is selected

Accessibility

The RadioGroup component follows WAI-ARIA guidelines for radio groups:

  • Uses semantic <fieldset> and <legend> elements
  • Proper grouping of related radio buttons
  • Keyboard navigation between options
  • Focus states with visible indicators
  • Proper disabled states
  • Integrates with form validation

Keyboard Interaction

  • Tab - Move focus to the radio group
  • Space - Select the focused radio button
  • Arrow Up/Left - Move to previous radio button in the group
  • Arrow Down/Right - Move to next radio button in the group