Widgets

/

layout

Aspect

Keeps its object at an aspect ratio.

Also written AspectRatio; layr format rewrites these to Aspect.

A 16:9 frame at any width

Aspect keeps its object at a width-to-height ratio, whatever width it gets. Thumbnails, video frames and maps keep their shape on every screen.

LAYR
Column(
  .config(w: fill, gap: 8)
  Aspect(
    .config(ratio: 1.78)
    .obj(
      Container(
        .config(
          w: fill
          h: fill
          color: LinearGradient(.colors(ink, violet))
          cornerRadius: 14
          objAlign: mid
        )
        .obj(Text(.config(color: white) .obj('16 : 9')))
      )
    )
  )
  Text(
    .config(size: 13, color: muted)
    .obj('Resize the preview: the height follows the width.')
  )
)

Config keys

KeyTypeDefaultMeaning
rationum1Width / height.
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.
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: one object, the default slot