Builder API
import { Deck, PALETTE } from "excalideck";const deck = new Deck(options);const f = deck.frame("Slide title", frameOptions); // one per slide, in order// ...draw on f...deck.save("talk.excalidraw");All coordinates are relative to the frame’s top-left, and frames are 1600×900 by default. Every drawing method
returns a handle, { el, id, x, y, w, h, cx, cy, right, bottom }, that you can pass to arrow() or use to place other
shapes: x: api.right + 80.
Run scripts with excalideck build talk.mjs, which resolves the excalideck import wherever it’s installed
(Write decks as code).
new Deck(options)
Section titled “new Deck(options)”| Option | Default | |
|---|---|---|
width, height |
1600, 900 |
the frame size |
columns |
4 |
frames per row when they’re placed on the canvas automatically |
seed |
1 |
changes the hand-drawn wobble. The output is the same every time for a given seed |
font |
"excalifont" |
excalifont, virgil, helvetica or mono |
roughness |
1 |
0 clean, 1 sketchy, 2 very sketchy |
background |
"#ffffff" |
deck.save(path) writes the file. deck.toJSON() returns the scene without writing it.
deck.frame(title, options)
Section titled “deck.frame(title, options)”| Option | Values |
|---|---|
transition |
morph (default), zoom, camera, fade or cut: how the deck arrives at this slide |
appear |
fade (default), pop, draw or rise: how new shapes arrive |
speed |
slow or fast |
stagger |
false to bring new shapes in all at once |
at |
[x, y], the frame’s place on the canvas. Default: the next place on a grid. Put it far away for camera |
The frame is named NN title [tags], which is what the player reads, so a deck built by a script is a deck you can go
on editing in Excalidraw. Transitions describes the options.
Drawing
Section titled “Drawing”| Method | |
|---|---|
f.title(text, o?) |
a 48px heading at (64, 44) |
f.caption(text, o?) |
20px grey text along the bottom edge |
f.text(text, { x, y, size = 20, color, align, opacity }) |
align is "left", "center" or "right"; for center, x is the centre |
f.box(label, o) |
a labelled shape. See below |
f.region(label, o) |
a dashed grouping box with its label top-left, placed behind the shapes it holds. See below |
f.arrow(from, to, o?) |
an arrow bound to a shape at each end. See below |
f.badge(n, { x, y, color }) |
a 46px numbered circle, for numbering steps |
f.row(labels, { x, y, gap = 60, ...boxOptions }) |
boxes left to right; returns their handles |
f.column(labels, { x, y, gap = 40, ...boxOptions }) |
boxes top to bottom; returns their handles |
f.measure(text, size) |
{ w, h } of the text, in pixels |
f.box(label, options)
Section titled “f.box(label, options)”| Option | |
|---|---|
x, y or cx, cy |
the top-left corner, or the centre |
w, h |
the size. Leave them out to fit the label |
shape |
rectangle (default), ellipse or diamond |
color |
a PALETTE key (default blue) |
stroke, fill, textColor |
hex colours, overriding the palette |
size |
the label’s font size in px (default 20) |
dashed |
a dashed outline |
opacity |
0 to 100 |
strokeWidth |
Use \n in a label to break it over two lines.
f.region(label, options)
Section titled “f.region(label, options)”| Option | |
|---|---|
x, y, w, h |
where it goes |
around: [handles] |
or: fit it around these shapes, with pad (default 40) on each side and top (default 50) for the label |
color, fill, opacity |
|
size |
the label’s font size (default 24) |
solid |
a solid outline instead of dashed |
A region with the same label as a box on the slide before is what that box grows into.
f.arrow(from, to, options)
Section titled “f.arrow(from, to, options)”from and to are handles from box(), region() and the rest.
| Option | |
|---|---|
label |
text on the arrow |
labelSize |
default 18 |
via: [[x, y], ...] |
bend points. Sharp corners, unless curved: true |
color |
a hex colour, such as PALETTE.red[0] |
strokeWidth, dashed, opacity |
|
both |
an arrowhead at each end |
none |
no arrowhead |
PALETTE
Section titled “PALETTE”blue, green, violet, yellow, orange, red, cyan, teal, pink and gray: Excalidraw’s colours. Each is
[stroke, fill], so PALETTE.red[0] is "#e03131", the red for a highlighted arrow.
Checking from code
Section titled “Checking from code”import { check, formatReport } from "excalideck/check";const report = check(deck.toJSON()); // { slides, transitions, errors, warnings }console.log(formatReport(report));report is the same document excalideck check --json prints (The layout checker).