mosaic.grids constructors

The contents below link to each definition. Function entries show the signature, then a description, then the parameters with their types and defaults; variable entries show the declared type.

Creates a structural leaf cell in a Mosaic grid tree.

cell(
  ..identifier,
  content: none,
  id: none,
  inset: auto
) -> dictionary
Description

A cell is where slide content lands. Its id must be a non-empty string, unique within the tree, and may not be one of the reserved plane ids background or foreground. Pass it positionally or through id:, but not both.

#mosaic.grids.rows(
  mosaic.grids.track(auto, mosaic.grids.cell("header")),
  mosaic.grids.cell("body"),
)

Styling

Cells are structural only. Every rendered cell is labeled <mosaic-cell-ID>, so appearance comes from native Typst rules: set text and friends for properties of the content, set block for the cell’s own block.

#show label("mosaic-cell-body"): set text(size: 0.9em)
#show label("mosaic-cell-body"): set block(fill: luma(240))
Arguments
..identifierarguments
The cell id, as the sole positional argument. Give it here or through id:.
contentcontent | none
Fixed content rendered in place of a slide body, so the surrounding slide supplies no block for this cell.
idstr | none
The cell id, when it is not passed positionally.
insetauto | length | relative | dictionary
Native Typst inset applied inside the cell’s labeled block. auto uses the spacing.inset configured on setup.

Associates an explicit native track size with one child of columns or rows.

track(size, child) -> dictionary
Description

Unwrapped children of a split take 1fr and therefore share the space evenly. Wrap one in track to give it a size of its own.

#mosaic.grids.rows(
  mosaic.grids.track(auto, "header"),  // as tall as its content
  "body",                              // 1fr, taking the rest
  mosaic.grids.track(2em, "footer"),   // a fixed strip
)

The wrapper is temporary: columns or rows unwraps it while constructing the split, so a track value never appears in a resolved tree.

Arguments
sizeauto | length | ratio | relative | fraction
Native Typst grid track size. auto sizes to the child’s content, a length or ratio fixes it, and a fraction such as 2fr takes a share of what remains.
childstr | dictionary
The child to size: a string cell id, or a canonical Mosaic grid node built with cell, columns, or rows.

Splits the available width, arranging its children as columns.

columns(gutter: 0pt, stroke: none, ..children) -> dictionary
Description

Children may be given in three forms, freely mixed:

Each unwrapped child receives a 1fr column, so an unadorned columns divides the width evenly.

#mosaic.grids.columns(
  gutter: 1em,
  stroke: 0.5pt + gray,
  mosaic.grids.track(2fr, "left"),
  "right",
)
Arguments
gutterauto | length | ratio | relative | fraction
Native Typst track size used between adjacent columns.
strokenone | stroke
Stroke drawn along each interior column boundary, centered in the gutter. A gutter of 0pt leaves the stroke sitting directly between the columns.
..childrenarguments
The columns: string cell ids, Mosaic grid nodes, or values wrapped with track. At least one is required.

Splits the available height, arranging its children as rows.

rows(gutter: 0pt, stroke: none, ..children) -> dictionary
Description

Children take the same three forms as in columns: a string cell id, a Mosaic grid node, or either wrapped in track. Each unwrapped child receives a 1fr row.

#mosaic.grids.rows(
  gutter: 0.7em,
  mosaic.grids.track(auto, "header"),
  mosaic.grids.columns(gutter: 1em, "left", "right"),
  mosaic.grids.track(auto, "footer"),
)
Arguments
gutterauto | length | ratio | relative | fraction
Native Typst track size used between adjacent rows.
strokenone | stroke
Stroke drawn along each interior row boundary, centered in the gutter.
..childrenarguments
The rows: string cell ids, Mosaic grid nodes, or values wrapped with track. At least one is required.