Ask the assistant
0/400
Your question is processed by an AI service and kept to improve answers. Do not enter personal data.

    Transform

    Applies a geometric transformation to the child: rotation, scale, translation, reflection — and rotations in the third dimension. The transformation is drawn on top of the layout: the space the child takes in its parent does not change .

    Type: single-child

    Transform rotate:0.785
      SizedBox width:80 height:80
        ColoredBox color:#4f46e5

    Parameters

    All transformations can be set together. They combine into one matrix in a fixed order : translation, perspective, rotateX , rotateY , rotate , scale, reflection. The order is the same in the app and on the site, so Transform rotate:0.5 scale:2 means the same thing in both.

    Parameter Type Default Description
    translateX double — Horizontal shift, pixels
    translateY double — Vertical shift, pixels
    translateZ double — Depth along the line of sight, pixels: positive — toward the viewer
    rotate double — Rotation in the plane, in radians ( 3.14159 — half a turn)
    scale double — Uniform scale
    scaleX double — Horizontal scale (if there is no scale )
    scaleY double — Vertical scale (if there is no scale )
    flipX bool false Mirror horizontally
    flipY bool false Mirror vertically
    perspective double — Distance to the viewer, pixels, for rotateX / rotateY : the smaller, the stronger the depth (600–1200 for a typical card). Without it a 3D rotation just flattens
    rotateX double — Rotation around the horizontal axis, radians: the top edge moves away from the viewer or toward them
    rotateY double — Rotation around the vertical axis, radians: the card turns like a door
    backface bool true Whether to draw the child when it is turned with its back to the viewer (more than 90° around X or Y). false hides the back side
    alignment string center The point the transformation goes around: center , topLeft , bottomRight and so on
    filterQuality string — Redraw quality when scaling (app only)

    Nested structures

    #origin

    Offset of the transformation point from the chosen alignment , in pixels.

    Transform rotate:0.3 alignment:topLeft
      #origin x:10 y:5
      SizedBox width:80 height:80
        ColoredBox color:#7c3aed

    Examples

    Scale and shift

    Transform translateX:20 translateY:10 scale:1.2
      Text "Shifted and enlarged"

    Reflection

    Transform flipX:true
      Text "Mirrored"

    A card turned away from the viewer

    Transform perspective:800 rotateY:0.4
      SizedBox width:160 height:100
        ColoredBox color:#36345E

    Rotation around a corner

    Transform rotate:-0.2 alignment:bottomLeft
      SizedBox width:120 height:60
        ColoredBox color:#059669

    Differences between the app and the site

    • The order of transformations is the same.
    • filterQuality is not read on the site.
    • 3D rotations ( perspective , rotateX , rotateY , translateZ ) depend on the browser engine. Check the result in a real browser, not only in a page snapshot.

    Best practices

    • Radians, not degrees. Degrees to radians: degrees × 3.14159 / 180 .
    • The layout does not move. A shifted Transform is drawn in the new place but occupies the old one: neighboring elements do not move around it. For a real offset in the layout use Padding or Align .
    • For smooth motion wrap it in an animation (see Animation ) instead of changing values in jumps.

    See also