CUI

Components / Feedback

Alert

An inline message in a tone of information, success, warning or danger, which can be dismissed.

Functions: cui_alert

Alert

Usage

cui_alert(ui, "Payment received", .description = "Paid on November 5.", .tone = CUI_TONE_SUCCESS);
cui_alert(ui, "Storage almost full", .tone = CUI_TONE_WARNING, .dismissible = true);

Tones: CUI_TONE_NEUTRAL (info), SUCCESS, WARNING, DANGER. Returns false once dismissed.

Returns true while the alert is shown, so if (!cui_alert(...)) tells you it is gone. The library remembers the dismissal itself, under the alert's title, and a dismissed alert draws nothing from then on. To show the same text again later, give it a new key: "Storage almost full##2" shows the same title. An alert without dismissible always returns true, and whether to show it at all is your own if. Each tone brings its own icon, which icon replaces. description is a second, wrapping line under the title. For news about the whole view use a banner, and for something that just happened use a toast.

Keyboard

  • The alert only displays. Its dismiss button, when it has one, takes Tab, and Enter or Space presses it.

Options of cui_alert

OptionTypeDefaultDescription
.descriptionconst char *A second line of smaller text.
.tonecui_toneOne of CUI_TONE_NEUTRAL, CUI_TONE_INFO, CUI_TONE_SUCCESS, CUI_TONE_WARNING, CUI_TONE_DANGER, CUI_TONE_VIOLET, CUI_TONE_TEAL, CUI_TONE_ROSE or CUI_TONE_ACCENT.
.iconconst char *An icon: a CUI_ICON_* constant, or a string from another icon font.
.dismissibleboolShows a close button.

Related

  • Progress, meter, spinner and skeleton: Ways to show waiting and amounts: a progress bar, a meter against a limit, a spinner, a gauge and placeholder shapes for content that is loading.
  • Toast: A short message that appears in a corner and goes away by itself, with an optional action.
  • Empty state: What to show where there is nothing yet: an icon, a title, a line of help and an action.
  • Banner and countdown: A full-width announcement that can be dismissed, and a countdown to a moment in time.