Widgets

/

content

Span

Inline text runs inside Text: Text(Span(.config(weight: bold) 'Bold'), ' and plain').

Also written RichText; layr format rewrites these to Span.

Mixed styles in one line

Span styles a run of text inside a Text: a bold word, a coloured price, a struck-out old value. The runs flow and wrap together as one paragraph.

LAYR
Text(
  .config(size: 17, lineHeight: 1.5)
  Span(.config(weight: semibold) .obj('Room B'))
  ' is free at '
  Span(.config(color: accent, weight: semibold) .obj('10:30'))
  ' for '
  Span(.config(color: faint, strike: true) .obj('€60'))
  ' '
  Span(.config(weight: semibold) .obj('€48'))
  '.'
)

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.
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

  • .objs: several objects, the default slot

Events

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