Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commitdd348ac6c3

README.md

richText

Read-only multi-colored text widget. Pass a flat list of { text, color, italic?, monospace? } segments and the renderer builds a single-flow LayoutJob from them — no edit buffer, no cursor, no input handling. The same segment shape is consumed by TextInput when props.segments is set; Z.codeEditor builds segments via the highlighter modules under zui.highlight.* and passes them to TextInput.

Exports

  • richText(segments: { RichTextSegment }?, opts: RichTextOpts?) -> any — build a styled-text widget. The module returns this function directly.

Types:

  • RichTextSegment = { text: string, color: string?, italic: boolean?, monospace: boolean? }
  • RichTextOpts = { id: string?, classes: (string | { string })?, style: { [string]: any }? }

Usage

local richText = require("@builtin::modules.zui.widget.richText")
richText({
    { text = "hello ", color = "#fff" },
    { text = "world",  color = "#0E639C" },
})

Notes

  • Read-only: no edit buffer, no cursor, no input handling. Use Z.codeEditor or TextInput directly when text needs to be editable.
  • The renderer produces a single-flow LayoutJob from the segments, so a mid-sentence color change does not break line wrapping.