Components / Actions
Status button
A button that shows the progress of the work it started: a spinner while busy, then a check or an error.
Functions: cui_status_button

Usage
static cui_status status;
if (cui_status_button(ui, "Save changes", status, .success_label = "Saved")) { status = CUI_STATUS_BUSY; start_save(); }
/* later: status = CUI_STATUS_SUCCESS (or CUI_STATUS_ERROR), then back to CUI_STATUS_IDLE */
Shows the life of the work it started: idle, a spinner while busy, a check or an error. The width springs between states and the content cross-fades. Clicks only count while idle.
Returns true on the frame it is clicked while status is CUI_STATUS_IDLE. status is your variable, passed by value: the button never changes it. Set CUI_STATUS_BUSY when the work starts, CUI_STATUS_SUCCESS or CUI_STATUS_ERROR when it ends, and CUI_STATUS_IDLE again once the result has been seen. Without options the busy text is the label followed by an ellipsis, the success text is "Done" and the error text is "Failed"; busy_label, success_label and error_label replace them. variant is primary by default. A plain button with .loading = true shows only the spinner.
Keyboard
- Tab focuses the button, and Enter or Space presses it.
Options of cui_status_button
| Option | Type | Default | Description |
|---|---|---|---|
.busy_label | const char * | label + "..." | default label + "..." |
.success_label | const char * | "Done" | default "Done" |
.error_label | const char * | "Failed" | default "Failed" |
.icon | const char * | An icon: a CUI_ICON_* constant, or a string from another icon font. | |
.variant | cui_button_variant | primary | default primary |
.size | cui_control_size | One of CUI_SIZE_MD, CUI_SIZE_SM or CUI_SIZE_LG. |
Related
- Reactions: Reaction buttons with a count each, as under a message or a post.
- Confirm button: A button for destructive actions that asks for a second click before it fires.
- Speed dial: A round floating button that fans out a few related actions.
- Toggle group: A row of joined toggle buttons, each on or off, or exactly one on at a time.