Skip to content

Text

Renders a text string inside a configurable HTML container. Supports variants for headings, body text, and visual styling.

new Text("Hello, world!")
PropertyTypeDefaultDescription
idStringOptional component ID
textStringThe text content (may contain template expressions like ${value})
containerTextContainerdivHTML element used to wrap the text
variantsList<TextVariant>[]Visual modifiers
styleString""Inline CSS
cssClassesString""CSS class names
attributesMap<String, String>{}Additional HTML attributes
ValueHTML element
div<div> (block, default)
span<span> (inline)
h1h6Heading levels
p<p> paragraph
small<small>
strong<strong>
em<em>
ValueDescription
primaryPrimary colour
secondaryMuted / secondary colour
tertiaryEven more muted
successGreen
errorRed
warningYellow / amber
bodyNormal body text size
largeLarger text
smallSmaller text
boldBold weight
// Heading
new Text("Page title", TextContainer.h2)
// Paragraph
new Text("Introductory paragraph.", TextContainer.p)
// Error message
new Text("Something went wrong!", List.of(TextVariant.error, TextVariant.bold))
// Template expression (interpolated at render time)
new Text("Welcome, ${user.name}!")
// Inline span
new Text("inline", TextContainer.span)
new Text("plain string")
new Text("text", TextContainer.h1)
new Text("text", List.of(TextVariant.bold))
new Text("id", "text")
new Text("id", "text", TextContainer.h2)
new Text("id", "text", List.of(TextVariant.success))