Overview
TheRadioGroup class creates a group of radio buttons where only one option can be selected at a time. It provides a clear visual representation of all available options and is ideal for mutually exclusive choices.
Inheritance
Constructor
Parameters
The unique identifier for the radio group node in the DOM.
The label text to display for the radio group.
The radio button options to display. Can be an array, Promise, or Observable of OptionChild objects.
The initial selected value of the radio group.
Whether to display the node in a single line layout.
Material icon name to display with the radio group.
Custom error message to display when validation fails.
Whether the radio group is disabled.
Synchronous validator function(s) or control options.
Asynchronous validator function(s) for the radio group.
Action(s) to execute when the selection changes.
Properties
| Property | Type | Description |
|---|---|---|
id | string | The unique identifier for the node |
placeholder | string | The label text for the radio group |
type | 'radiogroup' | The node type (read-only) |
value | OptionChild[] | The radio button options |
selectedValue | string | The currently selected value |
singleLine | boolean | Whether displayed in single line layout |
icon | string | Material icon name |
errorMessage | string | Custom error message |
disabled | boolean | Whether the node is disabled |
validator | Validator | AbstractControlOptions | Synchronous validators |
asyncValidator | AsyncValidatorFn | Asynchronous validators |
action | Action | Action[] | Associated actions |
hint | string | Hint text to display |
autoFocus | boolean | Whether to auto-focus on load |
Methods
getOptions()
Returns the current list of radio button options.getNativeElement()
Returns the native DOM element for this node.Usage Example
Best Practices
When to Use RadioGroup
- 2-5 options: Radio groups work best with a small number of visible options
- Mutually exclusive: When only one choice should be selected
- Important choices: When you want all options visible at once
- Quick selection: When users should see and compare all options immediately
When to Use Alternatives
- Many options (6+): Use Dropdown instead
- Multiple selections: Use Checkbox or Dropdown with
multiple: true - Searchable options: Use AutoComplete for better user experience
Accessibility
RadioGroup nodes are rendered as native radio button groups with proper ARIA attributes and keyboard navigation support. Users can navigate options using arrow keys and select with Enter/Space.Related Node Types
- Dropdown - For many options in a compact format
- AutoComplete - For searchable single selection
- Checkbox - For independent yes/no choices
- SelectableNode - Base class for all selection nodes
