17  Theme Reference

See Theming for the narrative version and the worked custom-theme example.

17.1 theme()

typ.theme(palette: (:), node-presets: (:), edge-defaults: (:), edge-presets: (:))

All four arguments are dictionaries. theme() validates every preset value as a dictionary and applies the closed edge-style schema (see Edge style keys) to edge-defaults and every entry of edge-presets. node-presets entries stay open for custom builder fields, with their known core fields type-checked (see Node style keys).

typ.neutral-theme is typ.theme() — all four dictionaries empty; this is typ.diagram’s own default when no theme: is given.

typ.resolve-theme(value) accepts a plain dictionary with the same four fields (useful for terser user theme files) — omitted fields default to empty, unknown fields error immediately. Prefer theme() directly when writing a new theme; resolve-theme exists mainly for diagram(theme:)’s own internal handling of themes passed as plain dictionaries.

17.2 Writing a theme file

See the full walkthrough in Writing your own theme file. The two rules worth repeating here: extend an existing preset with base.node-presets.kind + (..) rather than replacing it outright unless you mean to drop its other fields, and import every package function a theme file calls (node-type, edge-type, theme, shapes.*) — Typst modules don’t inherit the importing document’s bindings.

For a complete real theme’s own reference — its palette, its node/edge preset tables — see that theme’s own docs, e.g. typograph-zx.