mosaic.grids constructors

The overview below links to each definition. Function definitions show signatures with parameter and return types; variables show their declared types. Descriptions and defaults follow.

cell

Creates a structural leaf cell in a Mosaic grid tree.

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. Use a set rule for properties of the content and mosaic.surface for the cell’s own block.

#show label("mosaic-cell-body"): set text(size: 0.9em)
#show label("mosaic-cell-body"): mosaic.surface(fill: luma(240))
Signature
cell(
  ..identifier: arguments,
  content: content | none = none,
  id: str | none = none,
  inset: auto | length | relative | dictionary = auto
) -> dictionary
Parameters
  • ..identifier

    • Type: arguments
    • The cell id, as the sole positional argument. Give it here or through id:.
  • content

    • Type: content or none
    • Default: none
    • Fixed content rendered in place of a slide body, so the surrounding slide supplies no block for this cell.
  • id

    • Type: str or none
    • Default: none
    • The cell id, when it is not passed positionally.
  • inset

    • Type: auto or length or relative or dictionary
    • Default: auto
    • Native Typst inset applied inside the cell’s labeled block. auto uses the spacing.inset configured on setup.

track

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

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.

Signature
track(size: auto | length | ratio | relative | fraction, child: str | dictionary) -> dictionary
Parameters
  • size

    • Type: auto or length or ratio or relative or 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.
  • child

    • Type: str or dictionary
    • The child to size: a string cell id, or a canonical Mosaic grid node built with cell, columns, or rows.

columns

Splits the available width, arranging its children as columns.

Children may be given in three forms, freely mixed:

  • A string, which is shorthand for cell(id).
  • A node built with cell, columns, or rows, so splits nest to any depth.
  • Any of those wrapped in track to 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",
)
Signature
columns(
  gutter: auto | length | ratio | relative | fraction = 0pt,
  stroke: none | stroke = none,
  ..children: arguments
) -> dictionary
Parameters
  • gutter

    • Type: auto or length or ratio or relative or fraction
    • Default: 0pt
    • Native Typst track size used between adjacent columns.
  • stroke

    • Type: none or stroke
    • Default: none
    • Stroke drawn along each interior column boundary, centered in the gutter. A gutter of 0pt leaves the stroke sitting directly between the columns.
  • ..children

    • Type: arguments
    • The columns: string cell ids, Mosaic grid nodes, or values wrapped with track. At least one is required.

rows

Splits the available height, arranging its children as rows.

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"),
)
Signature
rows(
  gutter: auto | length | ratio | relative | fraction = 0pt,
  stroke: none | stroke = none,
  ..children: arguments
) -> dictionary
Parameters
  • gutter

    • Type: auto or length or ratio or relative or fraction
    • Default: 0pt
    • Native Typst track size used between adjacent rows.
  • stroke

    • Type: none or stroke
    • Default: none
    • Stroke drawn along each interior row boundary, centered in the gutter.
  • ..children

    • Type: arguments
    • The rows: string cell ids, Mosaic grid nodes, or values wrapped with track. At least one is required.