Cheatsheet
- Statements
-
node name ["text"] [placements] [key: value …]
edge a -> b ["text"] [key: value …](<-to write the target first,<->for both ends)
style name key: value …
diagram theme: nord background: #1e2229 text: (color: #e0e0e0)
default node|leaf|container|edge key: value …(a style every one of that kind wears; the more specific wins) - Labels
-
node parser— no text, so the node takes its name as its text.
node parser ""— deliberately blank.
"two / lines"—/with spaces either side breaks a line. - Containment
node server.docker "Docker"— a dotted name is a child. Declare the parent first. With no text of its own, it reads "docker".- Placement
-
above Xbelow Xleft of Xright of Xabove-left of X…below-right of X
level with X— share a center line;top|bottom|left|right level with Xshares that edge.
right of A and B— against the box that just bounds them both.
on X at top-right— stamped on X's box, overlapping it. The nine positions aretop-lefttop-centertop-rightleft-centercenterright-centerbottom-leftbottom-centerbottom-right.
A node takes as many placements as it needs. One on its own binds both axes. - Gaps
-
right of X (gap: wide)on the placement, orgap: tighton the node as its default. One ofnonetightnormalwide, and every one is a minimum. - Appearance
-
style: namefill: #191728border: noneline: #d2904e(an edge)overlap: allowurl: "https://example.com" - Contents
-
contents: (widths: match, align: center)— how a container's children sit when its title is wider than they are.widths:takesnaturalmatchfill;align:takesleftcenterright. - Body
-
shape: rectangle|document|none— the outline the node is drawn with;noneis text with no box, which is what an annotation is.
icon: name— the node is that picture, with no box.
badge: name— the picture sits beside the text and the node keeps its box.
deck: "text" ["text" …]— offset copies behind the box, one per text.
Pictures:diskdesktoplaptoppackagecubescubedatabase. - Text
-
Everything a text says about itself goes in brackets after it:
"Docker" (at: bottom-center, align: center)(color: muted)(size: small|normal|large)(wrap: 24)(characters, folds the text).at:takes the nine positions above. In a style, which has no text of its own, the bracket hangs off the key:text: (color: muted).
" / "in any text is a line break;\/is a literal slash.
"name / [dim]quieter[/dim]"draws those words in the text color ofstyle dim;\[is a literal bracket. - Links
-
from: rightto: leftname a side and curve the line.
between a and bsends it down the gap between two nodes, withverticallyorhorizontallyif they sit diagonally. - Comments
// to the end of the line, anywhere, including after a statement.