Maths, diagrams and sketches
Inline: $e^{i\pi} + 1 = 0$
$$\int_0^1 x^2\,dx = \tfrac{1}{3}$$
<Tex tex="\sum_{k=1}^{n} k = \frac{n(n+1)}{2}" />$…$ and $$…$$ are rendered with KaTeX at build time, so the browser loads no maths code for
them. LaTeX’s own delimiters work too: \(…\) inline and \[…\] for a display block (write \\(
for a literal \(). <Tex> (also <Math>) renders in the browser, for a formula that a component
builds; add block to set it on its own line.
Lines that light up, one click at a time
Section titled “Lines that light up, one click at a time”Steps after the opening $$ light the rows of an aligned, align, array, cases or matrix
block in turn, the way a code fence’s line steps do. The first step shows before any click; each
later one takes a click, and the other lines dim:
$$ {1|2|all}\begin{aligned}a &= b + c \\d &= e\end{aligned}$$A second group of options shifts it: $$ {2-3|all} {at: 3, finally: 'all'} starts its steps at
click 3 (or at: '+2', relative), and finally is what shows once the slide’s clicks go past the
last step (by default, the last step). startLine numbers the first line differently.
Macros and options
Section titled “Macros and options”katex in the headmatter passes options to every formula, macros included:
katex: macros: "\\RR": "\\mathbb{R}"Mermaid
Section titled “Mermaid”A mermaid fence draws a diagram in the deck’s colours:
```mermaid {theme: 'neutral', scale: 0.8, alt: 'Write, then present, then publish'}flowchart LR write --> present --> publish```theme (default, neutral, dark, forest, base) and scale steer that diagram, and alt
says what it shows for screen readers (without one, the diagram is labelled with its first line).
Any other key is Mermaid configuration for it ({look: 'handDrawn'}, {themeVariables: {…}}).
mermaid in the headmatter configures every diagram in the deck. The options are read, never run
as code, and a key Mermaid does not know is a warning in kadal-deck check.
The component spelling takes the same options as props (theme, scale, alt, config):
<Mermaid alt="Write, then present, then publish">{`flowchart LR write --> present --> publish`}</Mermaid>PlantUML
Section titled “PlantUML”```plantuml {scale: 0.8, alt: 'Login flow'}@startumlAlice -> Bob : helloBob --> Alice : hi@enduml```The diagram is drawn by a PlantUML server as SVG: the public one at plantuml.com unless the
headmatter names your own with plantUmlServer: https://plantuml.example.com/plantuml. The source is
sent to that server, so for private diagrams run one yourself.
Sketches: Excalidraw on a slide
Section titled “Sketches: Excalidraw on a slide”<Sketch> puts an Excalidraw drawing on a slide: the hand-drawn look, in the deck’s colours. Three
ways in:
// src/sketches.ts: drawn in code with the DSL (plain data; Excalidraw loads only when a sketch renders)import { sketch } from "@kadal/deck/sketch";
const s = sketch({ width: 1280, height: 600 });s.region("edge", { x: 440, y: 20, w: 420, h: 560, title: "Cloudflare Workers", tone: "accent" });s.node("w", { x: 470, y: 70, w: 360, h: 96, label: "Worker\nSSR + API", tone: "accent", region: "edge",});s.node("d1", { x: 470, y: 472, w: 160, h: 88, shape: "cylinder", label: "D1", tone: "pink", region: "edge",});s.arrow("w", "d1", { label: "only what is needed" });export const architecture = s.build();import { architecture } from "/src/sketches.ts";
<Sketch scene={architecture} steps={["edge", { focus: "edge", caption: "…" }, null]} height="660px"/><Sketch src="diagrams/flow.excalidraw" /> {/* saved on excalidraw.com, in public/ */}<Sketch>{`flowchart LR; a --> b`}</Sketch> {/* Mermaid, converted to Excalidraw */}A slide imports a file of the deck by its path from the deck’s folder, starting with /
(/src/sketches.ts); a ./ path doesn’t resolve from a slide. Or export the scene from
src/components.tsx inside a component of your own.
- Nodes:
box,pill,ellipse,diamond,cylinder,note,text; tones as for the bling components plusinkandmuted;fill: hachure,dashed,font: hand | normal | code. - Arrows pick the facing sides themselves (
from,to,fromShiftandviasteer them), take alabel, and belong to the regions of both ends. - Tours:
stepsshows the whole drawing first, then one click per entry lights a region and dims the rest, with a caption; the notes’[click]markers line up with them. - Converted Mermaid: flowchart, sequence, class, state and ER diagrams.
- Frames and groups in a saved
.excalidrawfile become regions.
The corner button (and its f hint) opens the real Excalidraw canvas in view mode to pan
and zoom. Colours are rewritten to theme tokens on export, so a sketch follows the theme menu and the
dark scheme; Excalidraw’s fonts are self-hosted by the Vite plugin under <base>excalidraw/fonts/, so
a sketch never reaches a font CDN.