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
) -> dictionaryA 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))..identifier | argumentsThe cell id, as the sole positional argument. Give it here or through id:. |
content | content | noneFixed content rendered in place of a slide body, so the surrounding slide supplies no block for this cell. |
id | str | noneThe cell id, when it is not passed positionally. |
inset | auto | length | relative | dictionaryNative 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) -> dictionaryUnwrapped 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.
size | auto | length | ratio | relative | fractionNative 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. |
child | str | dictionaryThe 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) -> dictionaryChildren may be given in three forms, freely mixed:
- A string, which is shorthand for
cell(id). - A node built with
cell,columns, orrows, so splits nest to any depth. - Any of those wrapped in
trackto give it an explicit track size.
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",
)gutter | auto | length | ratio | relative | fractionNative Typst track size used between adjacent columns. |
stroke | none | strokeStroke drawn along each interior column boundary, centered in the gutter. A gutter of 0pt leaves the stroke sitting directly between the columns. |
..children | argumentsThe 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) -> dictionaryChildren 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"),
)gutter | auto | length | ratio | relative | fractionNative Typst track size used between adjacent rows. |
stroke | none | strokeStroke drawn along each interior row boundary, centered in the gutter. |
..children | argumentsThe rows: string cell ids, Mosaic grid nodes, or values wrapped with track. At least one is required. |