Widgets

/

content

Text

Text. type gives it meaning (h1–h6, p, label, code) for accessibility and SEO.

Also written Txt; layr format rewrites these to Text.

A type scale

Text shows text. size is in design pixels, weight and lineHeight shape it, and type says what it is (h1–h6, p, label, code…) for screen readers and search engines, without changing how it looks.

LAYR
Column(
  .config(w: 320, gap: 8)
  Text(
    .config(size: 32, letterSpacing: -0.6, type: h1, weight: semibold)
    .obj('Room B')
  )
  Text(
    .config(size: 17, color: muted, lineHeight: 1.5)
    .obj(
      'A quiet studio for mixing, podcasts and rehearsals, booked by the hour.'
    )
  )
  Text(
    .config(
      size: 12
      color: accent
      letterSpacing: 0.6
      transform: upper
      weight: medium
    )
    .obj('Available today')
  )
)

Long text that must fit

maxLines with overflow: ellipsis cuts text off with … after that many lines, the same on every screen.

LAYR
Container(
  .config(w: 260, color: panel, cornerRadius: 12, padding: all(14))
  .obj(
    Text(
      .config(lineHeight: 1.4, maxLines: 2, overflow: ellipsis)
      .obj(
        'A studio booking page that shows the week, the free times and what is coming up, written once and laid out on every screen.'
      )
    )
  )
)

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.
typeh1 | h2 | h3 | h4 | h5 | h6 | p | label | code | span | strong | empSemantic type (sets the element and default style): h1–h6, p, label, code, span.
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.
w (width)len | fill | hugWidth: a length, fill (share the remaining space) or hug (fit content, default).
h (height)len | fill | hugHeight: a length, fill or hug (default).
minW (minWidth)lenMinimum width.
maxW (maxWidth)lenMaximum width.
minH (minHeight)lenMinimum height.
maxH (maxHeight)lenMaximum height.
aspect (aspectRatio)numAspect ratio (width / height), e.g. 16/9.
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.