Widgets

/

effects

Clip

Clips its object to a shape.

Cutting to a shape

Clip cuts its object to a shape: rect (with the Clip's cornerRadius), circle or ellipse. Anything outside the shape is not drawn.

LAYR
Row(
  .config(gap: 20, yAlign: mid)
  Clip(
    .config(size: 110, shape: circle)
    .obj(
      Container(
        .config(w: 110, h: 110, color: LinearGradient(.colors(violet, teal)))
      )
    )
  )
  Clip(
    .config(w: 170, h: 110, shape: ellipse)
    .obj(
      Container(
        .config(w: 170, h: 110, color: LinearGradient(.colors(ember, gold)))
      )
    )
  )
  Clip(
    .config(size: 110, cornerRadius: 28, shape: rect)
    .obj(
      Container(
        .config(w: 110, h: 110, color: LinearGradient(.colors(teal, gold)))
      )
    )
  )
)

For pictures, Image has cornerRadius of its own; Clip is for any object, whatever it contains.

Config keys

KeyTypeDefaultMeaning
shaperect | circle | ellipserectClip shape.
cornerRadiusradiusCorner radius for rect.
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.
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