Widgets

/

content

Image

An image. Give alt (or decorative: true). Per-frame sources: src: (m: 'a.jpg', w: 'a@2x.jpg').

Also written Img; layr format rewrites these to Image.

A cover image

Image shows a picture. Give it alt text (or decorative: true when it adds nothing for a screen reader). fit says how it fills its box: cover crops to fill, contain shows all of it. Images load lazily unless you set lazy: false.

LAYR
Column(
  .config(w: 320, gap: 10)
  Image(
    .config(
      w: fill
      h: 170
      alt: 'The LAYR link-preview card'
      cornerRadius: 14
      fit: cover
      src: '/og.png'
    )
  )
  Text(
    .config(size: 13, color: muted)
    .obj('fit: cover crops the picture to fill the box.')
  )
)

A round avatar

LAYR
Row(
  .config(gap: 12, yAlign: mid)
  Image(.config(size: 48, alt: 'LAYR', cornerRadius: 999, src: '/icon-512.png'))
  Column(
    Text(.config(weight: semibold) .obj('LAYR'))
    Text(.config(size: 13, color: muted) .obj('@dynshift'))
  )
)

Config keys

KeyTypeDefaultMeaning
srcsrcImage URL, or one per frame.
alttxtText alternative for screen readers.
decorativeboolPurely decorative: hidden from assistive technology.
fitcover | contain | fill | none | scaleDowncoverHow the image fills its box.
positionalignmidFocal point when cropped.
lazybooltrueLoad when near the viewport.
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).
size (s)sizeWidth and height together: size: 200 or size: (200, 120).
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.
cornerRadius (radius)radiusCorner radius.
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).

Events

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