Components / Actions
Confirm button
A button for destructive actions that asks for a second click before it fires.
Functions: cui_confirm_button
Usage
if (cui_confirm_button(ui, "Delete project", .icon = CUI_ICON_TRASH_2)) delete_project();
The first click morphs the button into a red "Click to confirm" with a countdown line; the second click fires. It disarms after timeout seconds (3), on Esc, or when you click elsewhere.
Returns true once, on the frame of the second click. You keep no state: the armed state is stored under the button's label, so two confirm buttons with the same label in one scope need different keys ("Remove##member" shows "Remove"). variant sets the look at rest, secondary by default; the armed look is always the danger color with a warning icon. timeout is in seconds, and 0 means 3. When the question needs a sentence use the confirm popover, and for an action that should take effort use the hold button.
Keyboard
- It disarms after
timeoutseconds (3), on Esc, or when you click elsewhere. - Tab focuses the button, and Enter or Space presses it, so two presses confirm. Esc disarms it while it has the focus.
Options of cui_confirm_button
| Option | Type | Default | Description |
|---|---|---|---|
.confirm_label | const char * | "Click to confirm" | default "Click to confirm" |
.icon | const char * | An icon: a CUI_ICON_* constant, or a string from another icon font. | |
.variant | cui_button_variant | secondary | resting look, default secondary |
.size | cui_control_size | One of CUI_SIZE_MD, CUI_SIZE_SM or CUI_SIZE_LG. | |
.timeout | float | 3 | seconds before it disarms, default 3 |
Related
- Confirm popover: A small question anchored to the button that opened it.
- Status button: A button that shows the progress of the work it started: a spinner while busy, then a check or an error.
- Toggle group: A row of joined toggle buttons, each on or off, or exactly one on at a time.
- Reactions: Reaction buttons with a count each, as under a message or a post.