class UI::Label

Overview

A read-only text label.

Displays a single or multi-line string with configurable font, color, alignment, and line limit.

Defined in:

ui/views/label.cr

Constructors

Instance Method Summary

Instance methods inherited from class UI::View

accept(visitor : PlatformVisitor) accept, accessibility_label : String | Nil accessibility_label, accessibility_label=(accessibility_label : String | Nil) accessibility_label=, background : Color | Nil background, background=(background : Color | Nil) background=, blur_radius : Float64 blur_radius, blur_radius=(blur_radius : Float64) blur_radius=, border_color : Color | Nil border_color, border_color=(border_color : Color | Nil) border_color=, border_width : Float64 border_width, border_width=(border_width : Float64) border_width=, clip_to_bounds : Bool clip_to_bounds, clip_to_bounds=(clip_to_bounds : Bool) clip_to_bounds=, container_query(name : String) : self container_query, container_query_name : String | Nil container_query_name, container_query_name=(container_query_name : String | Nil) container_query_name=, corner_radius : Float64 corner_radius, corner_radius=(corner_radius : Float64) corner_radius=, fill_screen! : self fill_screen!, fluid_height(min : String | Number, ideal : String | Number, max : String | Number) : self
fluid_height : UI::Fluid | Nil
fluid_height
, fluid_height=(fluid_height : UI::Fluid | Nil) fluid_height=, fluid_width(min : String | Number, ideal : String | Number, max : String | Number) : self
fluid_width : UI::Fluid | Nil
fluid_width
, fluid_width=(fluid_width : UI::Fluid | Nil) fluid_width=, hidden : Bool hidden, hidden=(hidden : Bool) hidden=, id : String | Nil id, id=(id : String | Nil) id=, maximum_height : Float64 | Nil maximum_height, maximum_height=(maximum_height : Float64 | Nil) maximum_height=, maximum_width : Float64 | Nil maximum_width, maximum_width=(maximum_width : Float64 | Nil) maximum_width=, minimum_height : Float64 | Nil minimum_height, minimum_height=(minimum_height : Float64 | Nil) minimum_height=, minimum_width : Float64 | Nil minimum_width, minimum_width=(minimum_width : Float64 | Nil) minimum_width=, opacity : Float64 opacity, opacity=(opacity : Float64) opacity=, padding : EdgeInsets padding, padding=(padding : EdgeInsets) padding=, root_fill : Bool root_fill, root_fill=(root_fill : Bool) root_fill=, shadow_color : Color | Nil shadow_color, shadow_color=(shadow_color : Color | Nil) shadow_color=, shadow_offset_x : Float64 shadow_offset_x, shadow_offset_x=(shadow_offset_x : Float64) shadow_offset_x=, shadow_offset_y : Float64 shadow_offset_y, shadow_offset_y=(shadow_offset_y : Float64) shadow_offset_y=, shadow_radius : Float64 shadow_radius, shadow_radius=(shadow_radius : Float64) shadow_radius=, swiftkit_state_handle : Pointer(Void) | Nil swiftkit_state_handle, swiftkit_state_handle=(swiftkit_state_handle : Pointer(Void) | Nil) swiftkit_state_handle=, test_id : String | Nil test_id, test_id=(test_id : String | Nil) test_id=

Constructor Detail

def self.new(text : String) #

[View source]

Instance Method Detail

def accept(visitor : PlatformVisitor) #
Description copied from class UI::View

Accept a platform visitor for rendering dispatch. Each concrete view type calls visitor.visit(self).


[View source]
def font : Font #

Font specification for the label text


[View source]
def font=(font : Font) #

Font specification for the label text


[View source]
def number_of_lines : Int32 #

Maximum number of lines (0 means unlimited)


[View source]
def number_of_lines=(number_of_lines : Int32) #

Maximum number of lines (0 means unlimited)


[View source]
def preferred_max_layout_width : Float64 | Nil #

Preferred wrapping width for native multi-line layout engines.

UIKit's UILabel uses this to compute a stable multi-line intrinsic content size when it is inside exact-width containers like UI::Card. Other renderers may ignore it.


[View source]
def preferred_max_layout_width=(preferred_max_layout_width : Float64 | Nil) #

Preferred wrapping width for native multi-line layout engines.

UIKit's UILabel uses this to compute a stable multi-line intrinsic content size when it is inside exact-width containers like UI::Card. Other renderers may ignore it.


[View source]
def strikethrough : Bool #

Phase 6.11 — strikethrough toggle. Renderers map to: SwiftUI / UIKit / AppKit : .strikethrough(true) Web : text-decoration: line-through Default false keeps existing labels visually unchanged. The Voyager Todos screen sets this true on a row's title label when the underlying todo is completed.


[View source]
def strikethrough=(strikethrough : Bool) #

Phase 6.11 — strikethrough toggle. Renderers map to: SwiftUI / UIKit / AppKit : .strikethrough(true) Web : text-decoration: line-through Default false keeps existing labels visually unchanged. The Voyager Todos screen sets this true on a row's title label when the underlying todo is completed.


[View source]
def text : String #

The text content to display

Setting #text after the renderer has emitted the SwiftUI hosting view propagates through the SwiftKit bridge: the matching APSKLabelState.text @Published field updates and SwiftUI re-renders the hosted Text without a tree rebuild. Setters issued before the view has been rendered are simply stored on the property; the next render seeds the reactive state from the new value.


[View source]
def text=(new_text : String) : String #

[View source]
def text_alignment : Alignment #

Text alignment within the label bounds


[View source]
def text_alignment=(text_alignment : Alignment) #

Text alignment within the label bounds


[View source]
def text_color : Color #

Text color (brand / explicit RGBA override). Only consulted when #text_color_role is nil — otherwise the role resolves to the appearance-tracking system color and this RGBA is ignored.


[View source]
def text_color=(text_color : Color) #

Text color (brand / explicit RGBA override). Only consulted when #text_color_role is nil — otherwise the role resolves to the appearance-tracking system color and this RGBA is ignored.


[View source]
def text_color_role : LabelRole | Nil #

Semantic Apple label-color role. When set, the AppKit / UIKit renderer resolves to NSColor.labelColor / UIColor.labelColor (and secondary / tertiary / quaternary variants) at render time, tracking appearance automatically. Default is LabelRole::Primary — the beauty-by-default HIG render. A host that wants a brand color sets text_color_role = nil and sets #text_color to the brand RGBA. Web / Android renderers ignore this field.


[View source]
def text_color_role=(text_color_role : LabelRole | Nil) #

Semantic Apple label-color role. When set, the AppKit / UIKit renderer resolves to NSColor.labelColor / UIColor.labelColor (and secondary / tertiary / quaternary variants) at render time, tracking appearance automatically. Default is LabelRole::Primary — the beauty-by-default HIG render. A host that wants a brand color sets text_color_role = nil and sets #text_color to the brand RGBA. Web / Android renderers ignore this field.


[View source]