Skip to content

Text

Text displays a string. It is used for headlines, paragraphs, labels and inline links. Set a Font for the typographic role, e.g. Title, and a Color for emphasis. A text with an Action or a link becomes interactive. For formatted HTML content, use Rich Text.

Text

VStack(
	Text("Hello Nago").Font(Title),
	Text("A plain paragraph of text."),
	Text("Colored and underlined").Color(SE0).Underline(true),
	Link(wnd, "A link to nago.dev", "https://www.nago.dev", "_blank"),
	MailTo(wnd, "Write us a mail", "info@example.com"),
).Alignment(Leading).Gap(L8)

Constructors

ConstructorDescription
func Text(content string) TTextCreates a text with the given content.
func Link(_ core.Window, text string, href string, target string) TTextCreates a link. An http or https href opens as usual, other paths navigate inside the app without reloading the page.
func LinkWithAction(text string, action func()) TTextCreates an underlined, interactive text which calls the action when clicked.
func MailTo(wnd core.Window, name string, email string) TTextCreates a mailto: link which opens the email client of the user.

Methods

Some setters return DecoredView instead of TText. Call them last in the chain or call the TText setters first.

MethodDescription
AccessibilityLabel(label string) DecoredViewAccessibilityLabel sets the label of the text.
Action(f func()) TTextAction executes the function when the component is clicked.
BackgroundColor(backgroundColor Color) DecoredViewBackgroundColor sets the color of the background.
Border(border Border) DecoredViewBorder draws a Border around the component.
Color(color Color) TTextColor sets the Color of the font.
Ellipsis(ellipsis bool) TTextEllipsis sets the flag to cut of text overflow with ellipsis.
FocusedBorder(border Border) TTextFocusedBorder sets the Border width, color and radius when the component is focused.
Font(font Font) TTextFont sets the size, style and width of the Text.
Frame(frame Frame) DecoredViewFrame sets the width, minWidth, maxWidth, height, minHeight and maxHeight.
FullWidth() TTextFullWidth sets the width to 100%.
HoveredBorder(border Border) TTextHoveredBorder sets the Border width, color and radius when component is hovered.
Hyphens(h Hyphens) TTextSets the hyphenation mode, e.g. HyphensAuto.
LabelFor(id string) DecoredViewMakes the text the label of the input element with the given id.
LineBreak(lb bool) TTextLineBreak de-/activates line breaking in between the Text.
Link(url, target string) TTextTurns the text into a link to the url, opened in the given browsing context.
Padding(padding Padding) DecoredViewPadding sets a top, right, bottom and left spacing.
PressedBorder(border Border) TTextPressedBorder sets the Border width, color and radius when the component is clicked.
Resolve(b bool) TTextResolve tries to resolve the current text content against the window bundle at render time to translate its contents.
Text(content string) TTextText is a convenience property setter method to set the content for a zero-value Text.
TextAlignment(align TextAlignment) TTextTextAlignment sets the position of the Text.
Underline(b bool) TTextUnderline underlines the Text.
Visible(visible bool) DecoredViewVisible decides whether a text is shown.
WhiteSpace(whiteSpace WhiteSpace) TTextSets how white space inside the text is handled.
WithFrame(fn func(Frame) Frame) DecoredViewWithFrame sets width, minWidth, maxWidth, height, minHeight and maxHeight using a function.
WordBreak(wordBreak WordBreak) TTextSets where lines may break inside words.

Related