lazy-layout
lazy-layout(direction: ttb, body)(source)Equalize the sizes of multiple side-by-side (or stacked) blocks along one axis, while keeping the overall container size equal to the largest block (not the full page size).
Wrap a multi-block layout with lazy-layout so that lazy-v or lazy-h markers
inside each block are resolved correctly. The function first measures the natural
size of the content (ignoring all lazy markers), then re-renders it at that fixed
size with the markers activated. This causes the fractional spaces to fill only the
remaining room inside each block up to the largest block's size, making all blocks
the same size without the container growing beyond the largest block.
The direction parameter controls which axis is equalized and which lazy marker
type is activated:
- Vertical directions (
ttb,btt): activateslazy-vmarkers, equalizes block heights. This is the default and matchesside-by-side(lazy-layout: true). - Horizontal directions (
ltr,rtl): activateslazy-hmarkers, equalizes block widths.
Mixing lazy-v and lazy-h markers inside the same lazy-layout call will panic.
Use side-by-side(lazy-layout: true) as a convenient shorthand for the vertical
case, or wrap a manual grid / stack directly:
// Vertical (default): equalize block heights
#components.lazy-layout(grid(
columns: (1fr, 1fr),
block(width: 100%)[
#lorem(10)
#components.lazy-v(1fr)
Bottom left.
],
block(width: 100%)[
#lorem(20)
#components.lazy-v(1fr)
Bottom right.
],
))
// Horizontal: equalize block widths
#components.lazy-layout(
direction: ltr,
stack(
dir: ltr,
block(height: 100%)[Left. #components.lazy-h(1fr) Right.],
block(height: 100%)[Longer left. #components.lazy-h(1fr) Right.],
),
)
Returns: content