Components / Feedback
Undo toast
A toast with an Undo action and a visible timer, for actions that can be taken back.
Functions: cui_toast_action_clicked

Usage
static int undo_toast; /* the handle; 0 matches no toast */
if (cui_button(ui, "Archive")) {
archive();
undo_toast = cui_toast(ui, "3 conversations archived", .action = "Undo", .show_timer = true);
}
if (cui_toast_action_clicked(ui, undo_toast)) unarchive();
show_timer adds a draining line along the bottom of the toast, so people can see how long Undo stays (6 seconds by default; hovering the stack pauses it).
The undo toast is cui_toast with two options. Call cui_toast once, on the frame the action happens, not on every frame: each call queues a new toast. It returns a handle, and handles start at 1. Keep the handle in a variable that outlives the frame and ask cui_toast_action_clicked(ui, handle) on the frames that follow. It returns true once, when the action button is pressed, which also dismisses the toast. The toast copies its strings, so they may be temporary. duration is in seconds, and a negative value keeps the toast until it is dismissed.
Keyboard
- The Undo button takes Tab, and Enter or Space presses it.
Related
- Toast: A short message that appears in a corner and goes away by itself, with an optional action.
- Button: Starts an action when clicked. It comes in six variants and three sizes, with an optional icon and a loading state.
- Onboarding checklist: A card with a progress ring and steps; the first unfinished step opens to show its description and action button.
- Banner and countdown: A full-width announcement that can be dismissed, and a countdown to a moment in time.