Skip to main content

Module text_widget

Module text_widget 

Source
Expand description

TextWidget โ€” a leaf widget that renders a localized text string.

TextWidget is the building block for every visible label in the framework. It delegates measurement and rasterization to the TextBackend and supports three overflow modes: [TextOverflow::Wrap] (default โ€” grows vertically), [TextOverflow::Ellipsis] with trailing, middle, or leading truncation, and a minimal markup subset ([label](url), *italic*, **bold**) with per-link click/hover dispatch.

Text and color accept either static values or reactive Signal/Prop bindings. The default color role is [TextRole::Primary], resolved against the active theme at paint time, so theme switches update text color without any explicit binding or rebuild.

Single-line / ellipsis text opts into shrink by default: an over-constrained stack compresses the label down to the ellipsis-glyph width before the label overflows. Call no_shrink to restore rigid behavior, or min_shrink_width to set a custom floor. Wrap-mode text is height-variable and therefore always rigid; opt it into compression with Shrinkable.

// Single-line label that truncates with a trailing ellipsis if too narrow:
let _w = TextWidget::new(lit!("Save document")).single_line();

Structsยง

TextWidget