RadioButton
Radio buttons allow users to select a single option from a list of choices.
Installation
Usage
Props
RadioButton
Extends RadioGroupPrimitive.Item
props.
Prop | Type | Default | Description |
---|---|---|---|
label | string | - | The text label for the radio button. |
value | string | - | The value associated with this radio button. |
disabled | boolean | false | When true, prevents user interaction. |
className | string | - | Additional Tailwind classes to apply. |
RadioGroup
Extends RadioGroupPrimitive.Root
props.
Prop | Type | Default | Description |
---|---|---|---|
value | string | - | The value of the selected radio button. |
onValueChange | (value: string) => void | - | Callback fired when selection changes. |
Examples
Basic Usage
Single Radio Button
Disabled States
Styling
The RadioButton component uses Tailwind CSS classes for styling. Default styling includes:
- Container dimensions: 329px × 44px (minimum height)
- Radio button size: 20px × 20px
- 2px border width
- Rounded full circles
- Primary color when selected
- Disabled state styling
- 8px gap between radio and label
States
Radio buttons have several visual states:
- Unselected: White background with base ink border
- Selected: Primary color fill with primary border
- Disabled unselected: Gray border
- Disabled selected: Gray fill and border
Accessibility
The RadioButton component:
- Uses
accessibilityRole="radio"
for proper semantic structure - Supports keyboard navigation within RadioGroup
- Maintains WCAG color contrast requirements
- Provides appropriate
accessibilityState
for checked and disabled states - Uses proper labeling with
aria-labelledby
- Ensures adequate touch target size (44px minimum height)