Text

Displays text with customizable style and size.

Basic Usage

Text("Hello, World!")

Options

Option Type Description Example
Style TextStyle Sets a preset text style Style(H1)
Size float32 Sets a custom font size in sp Size(24)

Text Styles

Style Description
BodyText Default body text (default)
H1 Heading 1 (largest)
H2 Heading 2
H3 Heading 3
H4 Heading 4
H5 Heading 5
H6 Heading 6 (smallest heading)
Caption Small caption text
Overline Small uppercase text

Examples

// Basic text
Text("Hello, World!")

// Heading styles
Text("Main Title", Style(H1))
Text("Section Title", Style(H2))
Text("Subsection", Style(H3))

// Caption and overline
Text("Image caption", Style(Caption))
Text("CATEGORY", Style(Overline))

// Custom font size
Text("Custom size", Size(20))

// Custom size overrides style
Text("Large heading", Style(H1), Size(48))

// Dynamic text
Text(fmt.Sprintf("Count: %d", counter.Get()))

// Text in layouts
Column([]any{
    Text("Welcome", Style(H2)),
    Text("This is the body text."),
    Text("Learn more", Style(Caption)),
})