Widgets

/

content

RichText

Text with styled runs written inside the string: (blue)[Blue], (24, bold)[Big], *bold*, _italic_, `code`, ~strike~, \n for a line break and a blank line for a paragraph. A slash prints markup as written: /(blue)[Blue]. Values from $name are always plain text. Its config styles the whole text, like Text's.

Styles inside the string

RichText writes styled runs inside one string. (style, style…)[text] styles the text in brackets, and *bold*, _italic_, `code` and ~strike~ mark words. Runs nest. Its own config styles the whole text, like a Text's.

LAYR
RichText(
  .config(
    size: 17
    lineHeight: 1.6
  )
  .obj('
    Room B is (teal)[free] at (accent, bold)[10:30] for ~€60~ *€48*.\n
    (13, muted)[Prices include _everything_. See (link: /docs/objects)[the docs] for `RichText`.]

    A blank line starts a paragraph. (hL.gold.40)[Highlights] work too.
  ')
)

The markup

WriteShows
(blue)[text], (#0d0d0d)[text], (accent)[text]a colour: named, hex or a theme colour
(green.50)[text]a colour at 50% opacity
(24)[text]a size, in design px
(weight.700)[text], (bold)[text], (italic)[text]weight and style; also underline, strike, code
(hL.gold.30)[text]a highlight behind the text, with its opacity
(link: /docs)[text]a link (in-app paths navigate without a reload)
(grey.90, bold, 35)[text]several styles at once
*bold* _italic_ `code` ~strike~marks; they need a space or punctuation around them, so snake_case and 2 * 3 stay as written
\na line break; a blank line starts a paragraph; other line breaks in the source are spaces
/(, /*, /_the markup as written; each further slash shows one slash (//(blue)[x] shows /(blue)[x])

Values from $name and ${expr} are always plain text, never markup, so a name with a * in it cannot restyle the page. A style the compiler does not know is shown as written, with warning L1018. The string may run over several lines between quotes.

Config keys

KeyTypeDefaultMeaning
size (fontSize)lenFont size in design px.
font (fontFamily)txtFont family, e.g. 'Geist'.
weight (fontWeight, wight)thin | light | regular | medium | semibold | bold | blackFont weight: thin…black or 100–900.
italic (italics)boolItalic style.
colorpaintText colour (a gradient paints the glyphs).
align (textAlign, textAlight, alignment)left | mid | right | start | end | justifyText alignment.
lineHeightnumLine height as a multiple of the font size.
letterSpacinglenSpace between letters.
underlineboolUnderline.
underlinePosauto | under | baselineUnderline position.
underlineSkipInkbooltrueSkip descenders when underlining.
strikeboolStrike-through.
transformnone | upper | lower | capitalizeCase transform.
overflowwrap | ellipsis | fade | scale | clipwrapLong text: wrap (default), ellipsis, fade, scale or clip.
maxLinesintMaximum lines before overflow applies.
selectablebooltrueAllow selection.
baseline (textBaseline)top | mid | bottom | baselineVertical alignment inside a line.
margininsetsSpace outside the object: all(8), sym(x: 8, y: 4), only(top: 8).
opacitynumOpacity from 0 to 1.
hide (hidden)boolRemoves the object from layout and the accessibility tree.
shrinknum1Shrink priority when space runs out. Lower shrinks first; 0 never shrinks.
flexnum1Share of remaining space for fill sizes.
cursorauto | pointer | text | grab | grabbing | move | notAllowed | crosshair | nonePointer cursor.
className (class)txtExtra CSS class names: styling hooks for your own stylesheet (hover rules, third-party CSS).

Slots

  • .obj: text, the default slot, required

Events

.on(...) accepts tap, press, hover, hoverEnd, focus, blur, key, drag, swipe, mount, unmount, visible.

Privacy

Cookies

Terms

Contact & grievances