Components / Selection
Checkbox, switch and radio
The three basic choices: a checkbox for an option, a switch for a setting that applies at once, and radio buttons for one of several.
Functions: cui_checkbox, cui_radio, cui_radio_group, cui_switch

Usage
cui_checkbox(ui, "Email notifications", &email, .description = "Product news, monthly.");
cui_switch(ui, "Wi-Fi", &wifi);
cui_radio(ui, "Monthly", &billing, 0);
cui_radio(ui, "Yearly", &billing, 1);
cui_radio_group(ui, "autosave", (const char *[]){ "Every change", "Every 5 minutes", "Only when I save" }, 3, &autosave);
Each returns true when it changes the value. The whole row, label included, is clickable. A press dips the box; checking overshoots a touch and settles, while clearing and keyboard toggles stay plain. The switch thumb stretches with its speed in flight, keeping its volume, and rounds out as it lands. A switch applies immediately; a checkbox is for choices confirmed later with a button. Options: description, disabled, indeterminate (checkbox). Keyboard: Space toggles.
Keyboard
- Space toggles.
Options of cui_checkbox, cui_radio, cui_switch
| Option | Type | Default | Description |
|---|---|---|---|
.description | const char * | A second line of smaller text. | |
.disabled | bool | Greyed out, and takes no input. | |
.indeterminate | bool | An animation with no amount, for work of unknown length. |
Related
- Slider: Picks a number, or a range with two thumbs, by dragging along a track.
- Segmented control: A compact set of two to five choices where one is always selected, for switching between views of the same content.
- Chips and rating: A chip is a small toggle for filters and tags. A rating picks a number of stars.
- Radio cards: One choice out of a few, shown as cards with a title and a line of explanation each.