struct Text
Swift
struct Text
Text label primitive — Phase 4: Yoga measure via canvas::Font + layout cache.
Sources/LavaUI/Text.swift:2
Constructors
init(_ string: String, color: Color = .primary, font: UIFont? = nil, hoverFill: Color? = nil, hoverColor: Color? = nil, cornerRadius: Float = 0, lineLimit: Int? = nil, align: Alignment = .topLeading, onClick: (() -> Void)? = nil)
Not documented.
Sources/LavaUI/Text.swift:38
Properties
var align: Alignment
Where the glyphs sit when the node is wider than they are.
A label that states its own width — .frame(width:), a grid cell, a
stack that stretches it — is a box with room left over, and until this
existed the text was always jammed against the leading edge of it.
The only way to centre one was .frame(width:alignment:), which is a
different thing entirely: it wraps the text in a box it does not own,
and that box is where the width, the background, the hover fill and
the cursor then land, while onClick stays on the text inside. The
control ends up hovering at one size and clicking at another.
So this is deliberately not a layout property. It moves the pen inside a node that already exists, and adds no node — which is what keeps a centred label the same click target as a leading one.
Both axes, and the same Alignment the frame takes, so moving a call
site across is the same word in a different place. The default is
.topLeading rather than .center, because top-leading is where a
text's glyphs have always gone and every existing caller is drawn
against that.
Sources/LavaUI/Text.swift:36
var color: Color
Not documented.
Sources/LavaUI/Text.swift:4
var cornerRadius: Float
Not documented.
Sources/LavaUI/Text.swift:14
var dumpDetail: String { get }
Not documented.
Sources/LavaUI/Text.swift:65
var hoverColor: Color?
Not documented.
Sources/LavaUI/Text.swift:13
var hoverFill: Color?
Row highlight under the pointer. Defaults to the theme's hover surface for clickable text, since an unclickable label highlighting on hover would be lying about being interactive.
Sources/LavaUI/Text.swift:12
var lineLimit: Int?
Not documented.
Sources/LavaUI/Text.swift:15
var onClick: (() -> Void)?
Closures break value equality (SwiftUI wart) — fine until Phase 5 skip-recompute.
Sources/LavaUI/Text.swift:8
var resolvedFont: UIFont? { get }
Resolved face for measure (explicit or environment default).
Sources/LavaUI/Text.swift:63
var string: String
Not documented.
Sources/LavaUI/Text.swift:3
Methods
func lineLimit(_ limit: Int?) -> Text
Limits wrapped rows and truncates the final visible row with an ellipsis when additional content exists.
Sources/LavaUI/Text.swift:146
func mountPrimitive() -> any AnyViewNode
Not documented.
Sources/LavaUI/Text.swift:71
func reconcilePrimitive(_ node: any AnyViewNode) -> any AnyViewNode
Not documented.
Sources/LavaUI/Text.swift:92