radio (cellium v0.1.0)
View SourceRadio button widget module for mutually exclusive options.
This module provides an interactive radio button widget that displays a label with a selectable button. Radio buttons are typically used in groups where only one option can be selected at a time.
Usage
Basic radio button:
radio:new(option_a, "Option A")Radio button with selected state:
Widget = radio:new(option_a, "Option A"),
SelectedWidget = Widget#{selected => true}Properties
label(string): Text label displayed next to the radio buttonselected(boolean): Whether the radio button is selected. Default: falsefocusable(boolean): Set to true by default
Display
- Unselected:
( ) Label - Selected:
(*) Label - When focused, foreground and background colors are swapped
Event Handling
Set the selected state in your update function when handling space or enter key events. Remember to deselect other radio buttons in the same group.
Summary
Functions
Handles keyboard events for the radio button. Sets selected to true on Space or Enter.
Creates a new radio button with default label 'Radio'.
Creates a new radio button with the specified label.
Renders the radio button in unfocused state.
Renders the radio button in focused state with inverted colors.
Functions
Handles keyboard events for the radio button. Sets selected to true on Space or Enter.
Creates a new radio button with default label 'Radio'.
Creates a new radio button with the specified label.
Renders the radio button in unfocused state.
Renders the radio button in focused state with inverted colors.