Skip to content

Label

Label preview

Label is a simple text display component. It wraps tview.TextView with themed defaults and a cleaner API.

Constructor func NewLabel(text string) *Label

Usage

label := components.NewLabel("Ready").
SetAlign(components.AlignLeft).
SetColor(tcell.ColorGreen).
SetBold(true).
SetWordWrap(true)
fmt.Println(label != nil)

Methods

Method Signature Description
Primitive func (l *Label) Primitive() *tview.TextView Primitive returns the underlying tview.TextView for advanced usage.
SetAlign func (l *Label) SetAlign(align Align) *Label SetAlign sets the text alignment.
SetBold func (l *Label) SetBold(bold bool) *Label SetBold sets whether the text is bold.
SetColor func (l *Label) SetColor(color tcell.Color) *Label SetColor sets the text color.
SetDynamicColors func (l *Label) SetDynamicColors(enabled bool) *Label SetDynamicColors enables or disables dynamic color tags. When enabled, you can use [color]text[-] syntax.
SetRegions func (l *Label) SetRegions(enabled bool) *Label SetRegions enables or disables region tags. When enabled, you can use ["region"]text[""] syntax for clickable regions.
SetScrollable func (l *Label) SetScrollable(scrollable bool) *Label SetScrollable enables or disables scrolling.
SetText func (l *Label) SetText(text string) *Label SetText sets the label text.
SetWordWrap func (l *Label) SetWordWrap(wrap bool) *Label SetWordWrap enables or disables word wrapping.

Types

type Align Align specifies text alignment.
ConstantDescription
AlignCenter
AlignLeft
AlignRight