ExcaliMath
A math-ready whiteboard that feels like Excalidraw — not like a separate tool bolted on.
ExcaliMath is an open-source companion plugin for Excalidraw that transforms it into a full-featured math whiteboard. It wraps — never forks — the @excalidraw/excalidraw React component, injecting three capability layers:
- Equation Layer — LaTeX authoring via KaTeX with live preview and click-to-edit
- Graph Layer — Function plotting via Plotly.js with multi-function support and templates
- Shape Libraries — 80+ curriculum-aligned STEM shapes across 6 subject packs
Built for students, teachers, and content authors. Available as a React component library (@excalimath/core) and as a standalone desktop app.
- Visual toolbar — click to insert fractions, integrals, Greek letters, matrices, and more. No LaTeX syntax knowledge needed.
- Write LaTeX directly or use the toolbar — live preview as you type
- Click any equation on the canvas to reopen and edit it
- 40+ pre-built expression library across 9 categories
- Graceful error handling with clear parse error messages
- Plot functions like
sin(x),x^2 + 2*xwith safe evaluation via mathjs (never useseval()) - Up to 5 colour-coded functions per graph
- Configurable axes: range, labels, grid, tick intervals
- Transparent or custom background colour
- CSV data import for scatter and line plots
- 7 preset templates: linear, parabola, trig, unit circle, number line, exponential, absolute value
- Click-to-edit restores full graph configuration
- Geometry (K-10): Triangles, circles, polygons, coordinate grid, number line, protractor
- Algebra (Gr 3-10): Fraction bars, algebra tiles, Venn diagrams, function machine
- Statistics (Gr 5-12): Bar chart, pie chart, histogram, scatter plot, box plot
- Physics / Circuits (Gr 8-12): 30 components — resistors, capacitors, transistors (NPN/PNP), all 7 logic gates, meters, diodes, and more
- Biology (Gr 5-12): Cell diagrams, DNA helix, mitosis stages, food web
- Chemistry (Gr 7-12): Bohr atom, periodic table tile, bond types, lab equipment
- Search across all packs, toggle packs on/off, import custom
.excalidrawlibfiles
- Native Windows/macOS/Linux app powered by Electrobun
- All features work fully offline — no browser or internet required
- Portable distribution (unzip and run)
- Dark and light theme support (auto-detects from Excalidraw)
- Round-trip fidelity: save and reopen
.excalidrawfiles with equations and graphs intact onSavecallback for integration with host applications- ARIA roles and keyboard accessibility
git clone https://github.com/tamerUAE/excalimath.git
cd excalimath
npm install
npm run devOpen http://localhost:5173 to see the demo.
cd apps/desktop
npx electrobun devimport { Excalidraw } from "@excalidraw/excalidraw";
import { ExcaliMath } from "@excalimath/core";
function App() {
const [api, setApi] = useState(null);
return (
<Excalidraw
excalidrawAPI={setApi}
renderTopRightUI={() =>
api ? (
<ExcaliMath
excalidrawAPI={api}
enabledPlugins={["equation", "graph", "library"]}
theme="auto"
onSave={(data) => console.log("Saved:", data)}
/>
) : null
}
/>
);
}| Prop | Type | Default | Description |
|---|---|---|---|
excalidrawAPI |
ExcalidrawImperativeAPI |
required | The Excalidraw API ref |
enabledPlugins |
Array<"equation" | "graph" | "library"> |
all enabled | Which plugins to show |
theme |
"light" | "dark" | "auto" |
"auto" |
Theme override (auto reads from Excalidraw) |
initialData |
ExcalimathSceneData |
— | Load a saved scene with auto-restore |
onSave |
(data: ExcalimathSceneData) => void |
— | Called on every insert/update for persistence |
ExcaliMath is a non-destructive companion wrapper — it composes with Excalidraw, never forks it.
excalimath/
├── packages/
│ └── core/ @excalimath/core — the plugin library
│ └── src/
│ ├── core/
│ │ ├── elementFactory.ts SVG → Excalidraw imageElement conversion
│ │ ├── stateBridge.ts Click-to-edit metadata detection
│ │ ├── roundTrip.ts Save/load restoration of equations + graphs
│ │ └── types.ts Shared type definitions
│ ├── plugins/
│ │ ├── equation/ KaTeX renderer + expression library
│ │ ├── graph/ Plotly renderer + mathjs evaluator + templates
│ │ └── geometry/ Shape library packs + registry
│ └── ui/
│ ├── ExcaliMath.tsx Main wrapper (toolbar + sidebar + tab navigation)
│ ├── EquationPanel.tsx LaTeX editor with live preview
│ ├── GraphPanel.tsx Function plotter with axis config
│ ├── LibraryPanel.tsx Shape browser with search + filtering
│ └── theme.ts Light/dark theme tokens
└── apps/
├── demo/ Web demo app
└── desktop/ Electrobun desktop app (isolated from npm workspaces)
- Wrapper Shell —
ExcaliMathcomponent injects a sidebar via Excalidraw'srenderTopRightUIhook. A single toggle button opens a panel with tabbed navigation. - Plugin Modules — Three independent modules (equation, graph, geometry), each independently loadable via the
enabledPluginsprop. - Element Factory — Converts rendered SVG (KaTeX MathML / Plotly charts / SVG gate symbols) into Excalidraw
imageElementobjects with embedded data URLs. - State Bridge — Tags inserted elements with
customDatametadata to enable click-to-edit. When a user clicks an equation or graph, the metadata is read to restore the editor with the original settings. - Round-Trip — Monitors the scene for ExcaliMath elements missing their SVG file data (e.g. after opening a saved file) and regenerates them from stored metadata.
| Concern | Library | Why |
|---|---|---|
| Equation rendering | KaTeX 0.16+ | Fastest LaTeX renderer; MathML output works in data URLs |
| Graph plotting | Plotly.js (SVG mode) | Declarative, high-quality SVG; no canvas/WebGL dependency |
| Function evaluation | mathjs | Safe expression parsing — never uses eval() |
| Component framework | React 18 | Matches Excalidraw's own stack |
| Build tooling | Vite + TypeScript (strict) | Fast HMR, clean ESM output for npm |
| Desktop shell | Electrobun | Native window with WebView2; sub-50MB bundle |
| Command | Description |
|---|---|
npm run dev |
Start the web demo in dev mode |
npm run build |
Build core library + demo app |
npm run build:core |
Build @excalimath/core only |
npm run typecheck |
TypeScript type checking |
For desktop app scripts, see apps/desktop/README.md.
- v0.1 — Equation Layer (KaTeX + live preview + expression library)
- v0.2 — Graph Layer (Plotly + mathjs + templates + CSV data)
- v0.3 — Shape Libraries (6 STEM packs, 80+ shapes, SVG logic gates)
- v1.0 — Integration-Ready Release (component API, round-trip fidelity, AuthorKit spec)
- vDesktop — Electrobun Desktop App (Windows, macOS, Linux)
We welcome contributions! See CONTRIBUTING.md for guidelines.
Please read our Code of Conduct before participating.
