Skip to content

Label

label · Elements · interactive

A caption for a control.

Import

cpp
#include "gbui/widgets/label.hpp"

Example

Nothing is downloaded until you press it.

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

OptionTypeDefaultWhat it does
forIdstd::string_viewThe control this names. Clicking the label focuses it, exactly as <label for> does, unless that control is disabled or read-only.
disabledboolfalse
readOnlyboolfalse
colorTokenToken::TextMuted
sizefloatkAuto
widthfloatkAuto
requiredboolfalseMarks the field as required, with the usual asterisk.

Released under the LGPL-3.0-or-later licence.