limu is a diagram layout engine in Go. It reads Mermaid and leaves the drawing to your program.
How it works
Mermaid and Pele lay out a diagram and write it as SVG for a browser to draw.
limu stops one step earlier, at the scene. A scene is the laid-out diagram as data. It says what each part is and where it goes, but not how it looks. A backend then draws it, whether that is limumygo on the GPU, the svg package, or one you write.
Because the scene holds no colors, it's laid out once and can be drawn any number of ways. Switching themes only redraws it, and a backend can also draw each part its own way.
The scene Boxes, paths and labels, with no style.
Kohu Drawn in limu’s light theme.

KohuDark Only the colors change.

Liquid Glass Each part drawn its own way, with MyGo’s glass.

An app can also ask the scene which part is under the pointer.
limu in your app
1go get github.com/firede/limu/limumygolimumygo draws a scene on the GPU with MyGo’s native UI and tells you which part is under the pointer. Lay out the diagram with the same fonts you draw it in.
1fonts := limumygo.DefaultFonts2sc, err := limu.Layout(src, &layout.Options{Measurer: fonts})3if err != nil {4 return err5}67// Draw the diagram in a view, and see which part was clicked.8w := limumygo.View(c, sc, &limumygo.Options{9 Look: style.Look{Theme: style.KohuDark()},10 Fonts: fonts,11})12if it := w.Clicked(); it != nil {13 fmt.Println("clicked", it.Role, it.ID)14}1go get github.com/firede/limuThe svg package writes a scene as SVG and leaves its colors as CSS variables, so a page can restyle it. limu and the svg package use only Go’s standard library.
1sc, err := limu.Layout(src, nil)2if err != nil {3 return err4}5out := svg.Render(sc, &svg.Options{Look: style.Look{Theme: style.Kohu()}})Explore
Examples
Every type of diagram limu supports, in each of its themes.
Playground
Write a diagram and see it laid out as you type.
Getting started
Lay out your first diagram and render it as SVG.
Theming
Change colors with themes and overrides, or draw parts yourself.
limu and Pele
Most of limu is ported function by function from Pele, the small, fast Mermaid renderer made by the Obsidian team. limu’s tests check that its layouts match Pele’s number for number. limu is open source under the MIT license.
Pele is named after the goddess of Hawaiʻi’s volcanoes. Limu is the Hawaiian word for the algae in its seas, and this site takes its colors from limu kohu, a red alga that grows in tide pools.