Skip to main content

Component | Text

Render text

ui.text("Hello world!")

Color & Size

Use the color and size properties to quickly change the appearance of the text. See the API reference below for the full list of supported values for each.

page.add(() => ui.stack(
[
ui.text("Users", { color: "primary", size: "xl" }),
ui.text("10 users found in database.", { color: "text-secondary" })
],
{ spacing: "4px" }
))

Nested Text

You can nest text components to create more complex text structures.

page.add(() => ui.text([
"It is ",
ui.text("very important", { color: "warning", style: { fontWeight: "600" }}),
" very important that you know this..."
]))

API reference

Function signature

ui.text(
text: string | TextComponent | Array<string | TextComponent>,
properties?: Partial<{
color: "text" | "text-secondary" | "primary" | "success" | "warning" | "danger" | "background",
size: "xs" | "sm" | "md" | "lg" | "xl",
style: Style
}>
)

Parameters

text

required string | TextComponent | Array<string | TextComponent>
The text to be displayed.

properties.color

optional string literalSDK v0.19.1+

Specifies the color of the text. Defaults to "text"

Options:

  • "text": Default text color
  • "text-secondary": Secondary text color, uses a lighter shade of the default text color
  • "primary": Primary color. Defaults to a shade of blue. Can be set via the theme.
  • "success": Success color, green.
  • "warning": Warning color, orange.
  • "danger": Danger color, red.
  • "background": Background color. Can be used over inverted backgrounds.

properties.size

optional string literalSDK v0.19.1+

Specifies the size of the text. Defaults to "md"

Options:

  • "xs": Extra small text
  • "sm": Small text
  • "md": Medium text
  • "lg": Large text
  • "xl": Extra large text

properties.style

optional Style

Directly style the underlying element using CSS. See the styling guide for more details on available style properties.