Module: ui.widgets.label
Source: ./ui/widgets/label.reef
Overview
ui/widgets/label.reef - Text display widget Part of reef-stdlib UI module
The Label widget displays static or dynamic text. It supports:
- Single-line and multi-line text
- Text alignment (left, center, right)
- Text wrapping
- Themed colors and fonts
Note: Text rendering requires a font to be loaded. The paint method draws a placeholder rectangle when no font is available.
Types
TextAlign (enum)
Variants:
LeftCenterRight
Objects
Label
Extends: widget.Widget
Fields:
| Name | Type |
|---|---|
text |
string |
align |
TextAlign |
multiline |
bool |
wrap |
bool |
custom_color |
core.Color |
use_custom_color |
bool |
font_size |
float |
use_custom_font |
bool |
proc init(id: widget.WidgetId, text: string)
Methods:
override shared fn kind(): string
exclusive proc set_text(text: string)
exclusive proc set_align(align: TextAlign)
exclusive proc set_multiline(multiline: bool)
exclusive proc set_wrap(wrap: bool)
exclusive proc set_color(color: core.Color)
exclusive proc set_font_size(size: float)
shared fn clone(): Label
D2 (docs/design/2026-09-08-ui-modernization.md): a SHALLOW copy. Setters mutate the receiver (reef-lang#62), so "give me a variant and leave the original alone" has to be asked for explicitly. Referenced objects are shared, not deep-copied.
shared fn preferred_size(th: theme.Theme): core.Size
exclusive proc layout(constraints: layout.Constraints, th: theme.Theme)
override exclusive fn handle_event(e: event.Event): widget.EventResult
override exclusive proc paint(surf: surface.Surface, th: theme.Theme)
Functions
fn text_align_left(): TextAlign
fn text_align_center(): TextAlign
fn text_align_right(): TextAlign
fn label(text: string): Label
fn label_with_align(text: string, align: TextAlign): Label
fn label_multiline(text: string, wrap: bool): Label
fn get_text_color(l: Label, th: theme.Theme): core.Color
fn get_font_size(l: Label, th: theme.Theme): float
fn string_length(s: string): int
String length helper (count characters until null)
Generated by reefc doc