span: Styled text

View source: R/span.R

spanR Documentation

Styled text

Description

span() creates a piece of text with its own style. Spans can be combined with c() and returned from a widget's render function or passed to label(). Newlines start new lines.

Usage

span(x = "", style = NULL, link = NULL)

## S3 method for class 'termr_text'
c(...)

Arguments

x

Text. A character vector is joined with newlines. May also be spans, to nest styles.

style

A style(); only colours and text attributes are used.

link

Optional link target (a URL or any string). Stored as metadata on the text for widgets that support it; not rendered yet.

...

Spans or character strings to combine.

Details

Spans nest: span(c(span("a"), span("b", s1)), s2) applies s2 to both pieces, with the inner style taking precedence.

Value

An object of class termr_text.

Examples

c(span("Status: "), span("OK", style(foreground = "green", bold = TRUE)))
span(c(span("bold "), span("and red", style(foreground = "red"))), style(bold = TRUE))

termr documentation built on Oct. 21, 2026, 5:13 p.m.