Label
label · Elements · interactive
A caption for a control.
Import
cpp
#include "gbui/widgets/label.hpp"Example
cpp
std::optional<std::string_view> label(Ui& ui, const Interaction& input, std::string_view id, std::string_view text, const LabelOptions& options = {});Returns the id to focus when the label was clicked, or nothing. The caller hands it to Interaction::focus, which keeps the toolkit from mutating interaction state behind a component's back: if (const auto target = label(ui, input, "f.name", "Repository", {.forId = "name"})) interaction.focus(*target);
API
LabelOptions
| Option | Type | Default | What it does |
|---|---|---|---|
forId | std::string_view | The control this names. Clicking the label focuses it, exactly as <label for> does, unless that control is disabled or read-only. | |
disabled | bool | false | |
readOnly | bool | false | |
color | Token | Token::TextMuted | |
size | float | kAuto | |
width | float | kAuto | |
required | bool | false | Marks the field as required, with the usual asterisk. |