Skip to content

Text ​

A text element displays one string in a single style.

go
title := scene.Text(1, "Welcome back").Style(&scene.Style{
	FontSize:   scene.Ptr[float32](24),
	FontWeight: scene.Ptr[uint32](600),
	TextColor:  scene.RGB(0xf4f4f5),
})

Large semibold text reading Welcome back

Signature ​

text
func Text(id uint64, text string) *Node
ParameterDescription
idStable nonzero element ID
textThe string to display. It is shown literally, with no markup or escaping

Styling ​

These properties apply to the text and are inherited by descendants, so you can set them once on an ancestor:

PropertyNotes
TextColorText color
FontSizeLogical pixels
FontWeight100 to 900
FontFamilyA system font, or one uploaded as a resource
ItalicItalic style
TextAlignLeft, center or right

Lines of text at different sizes and weights, in italic, in color and in Menlo

The root element of every view starts with the Helvetica font family until a style sets another.

Mixed styles within one string are not supported. To combine styles on one line, put several text elements in a row container.

One line combining plain, bold, colored and italic text

Four text elements in a row container.

Text cannot have children. It accepts the common node methods, including OnClick and Hover.

Available in other APIs ​

Released under the Apache License 2.0. The optional Zed editor component is GPL-3.0-or-later.