Radio Button
Radio buttons allow users to select a single option from a set of mutually exclusive options. Use radio buttons when only one selection is allowed.
Overview
Radio buttons are form controls that allow users to select exactly one option from a set of mutually exclusive options. They provide a clear visual indication of selection state and are always displayed in groups.
All radio button styles are built using design tokens, ensuring consistency across themes and hues. Use the interactive playground below to explore all available combinations.
Interactive Playground
Use the controls to customize the radio button and see how it looks in real-time. Toggle between themes and hues to see how radio buttons adapt to different contexts.
Anatomy
A radio button consists of a circular button element and an optional label. The button displays different visual states based on selection and interaction.
Variants & States
Radio buttons come in different states to fit various use cases. Each state provides clear visual feedback for user interaction.
Usage Guidelines
- Use radio buttons for mutually exclusive options.
- Use radio buttons when only one selection is allowed.
- Group related radio buttons together.
- Provide clear, descriptive labels for each radio button.
- Use radio button groups for 2-7 options.
- Ensure one option is selected by default when appropriate.
- Don't use radio buttons for multiple selections (use checkboxes instead).
- Don't use radio buttons for immediate actions (use buttons instead).
- Don't use radio buttons without labels.
- Don't use too many radio buttons in a single group (consider dropdown).
- Don't disable radio buttons without explaining why.
- Don't use radio buttons for single on/off toggles (use switches instead).
Accessibility
- Always associate radio buttons with labels using proper HTML structure or ARIA attributes.
- Ensure sufficient color contrast between radio button states and backgrounds.
- Provide keyboard navigation support (Arrow keys to navigate, Space to select).
- Use semantic HTML (`<input type="radio">` or proper ARIA roles).
- Group related radio buttons with `<fieldset>` and `<legend>`.
- Ensure radio buttons are large enough to be easily clickable (minimum 20px).
- Provide clear visual feedback for all interactive states (hover, focus, selected).
API Reference
Radio Button component props and types.
RadioButtonProps
interface RadioButtonProps {
selected?: boolean;
disabled?: boolean;
status?: "default" | "hovered" | "focused" | "pressed" | "disabled";
label?: string;
showLabel?: boolean;
onChange?: (selected: boolean) => void;
}Props
selectedbooleanfalsestatus"default" | "hovered" | "focused" | "pressed" | "disabled""default"labelstring"Radio Button"showLabelbooleantruedisabledbooleanfalseonChange(selected: boolean) => voidUsage Examples
Copyable code snippets for common radio button use cases.
Basic Radio Button
import { RadioButton } from 'beacon-ui';
<RadioButton />Radio Button with Label
import { RadioButton } from 'beacon-ui';
<RadioButton
label="Option 1"
/>Selected Radio Button
import { RadioButton } from 'beacon-ui';
<RadioButton
selected
label="Selected"
/>Disabled Radio Button
import { RadioButton } from 'beacon-ui';
<RadioButton
selected
disabled
label="Disabled"
/>Radio Button Group
import { RadioButton } from 'beacon-ui';
<div>
<RadioButton label="Option 1" />
<RadioButton label="Option 2" selected />
<RadioButton label="Option 3" />
</div>Radio Button with States
import { RadioButton } from 'beacon-ui';
<RadioButton label="Default" status="default" />
<RadioButton label="Hovered" status="hovered" />
<RadioButton label="Focused" status="focused" />
<RadioButton label="Pressed" status="pressed" />
<RadioButton label="Disabled" disabled />