CUI

Components / Basics

Text

Headings, body text, labels, links and inline code, with wrapping that avoids a lone last word.

Functions: cui_code, cui_label, cui_muted, cui_text

Usage

cui_heading(ui, "Settings", 1);          /* 1..4: 36, 28, 22, 17 pt; Geist for 28 and up */
cui_text(ui, "Body text wraps to the available width.");
cui_secondary(ui, "Supporting text in the secondary color.");
cui_muted(ui, "Small, muted text.");
cui_label(ui, "Medium weight label");
cui_textf(ui, "%d unread", unread);
cui_code(ui, "cui_button()");
if (cui_link(ui, "Read the docs")) open_docs();
cui_icon(ui, CUI_ICON_ZAP, 16, CUI_COLOR_ACCENT);

cui_text options: font (CUI_FONT_BODY, MEDIUM, DISPLAY, MONO), size, color, align, nowrap (one line with an ellipsis), tabular (aligned digits), width, line_height.

Wrapped text breaks like a careful typesetter: when a paragraph would end on a single word under a full line, the lines are rebalanced so at least two words share the last line. The number of lines never changes, so layout does not move. A nowrap line that is cut short with an ellipsis shows its whole text in a tooltip when the pointer rests on it; the text stays non-interactive, so the row or card around it keeps its clicks.

Hierarchy comes from size and color, not weight: CUI uses regular and medium only.

Keyboard

  • Text takes no focus. A link takes Tab, and Enter or Space follows it.

Options of cui_text

OptionTypeDefaultDescription
.fontcui_fontCUI_FONT_BODY (0)default CUI_FONT_BODY (0)
.sizefloattheme text_bodydefault theme text_body
.colorcui_colorforegrounddefault foreground
.aligncui_text_alignOne of CUI_TEXT_START, CUI_TEXT_CENTER, CUI_TEXT_RIGHT, CUI_TEXT_LEFT or CUI_TEXT_END.
.nowrapboolsingle line, ellipsis when it does not fit
.tabularbooltabular numbers
.selectableboolreserved
.widthcui_sizeWidth: CUI_FILL, CUI_FIT, CUI_PX(n) or CUI_PCT(n); unset uses the component's own.
.line_heightfloat1.45multiplier, default 1.45
.directioncui_directioninherited; AUTO examines this text

Related

  • Button: Starts an action when clicked. It comes in six variants and three sizes, with an optional icon and a loading state.
  • Icons: The Lucide icon set embedded as a font, used by name through CUI_ICON_* constants.
  • Badge, avatar and keycap: Small labels: a badge for a status or a count, an avatar for a person, and a keycap for a keyboard key.
  • Card and metric: A card is a surface that groups content. A metric shows one number with its change and an optional sparkline.