Syntax
A yuhwa file reads like notes: one thing per line, written the way you would say it. Start with arrows and add detail only where it helps.
web -> api -> dbName things, label the edges and add a little colour:
web "Storefront" -> api "Orders API": place order
api -> db "Postgres" [cylinder, amber]: SQLWhen a line gets long, put the props on their own lines below it:
title: Order pipeline
api "Orders API"
color: blue
sub: Kotlin · 3 pods
link: https://example.com/orders
db "Postgres" [cylinder, amber]
api -> db: SQL
style: dashedFor a large diagram, name the look once with classes and variables, stamp out repeated parts with components, and split the file with imports.
// starts a comment at the start of a line or after a space, so the // in https://example.com stays text. There is no other comment syntax: a line starting with # is an error.
The statements:
- Settings
- Nodes
- Edges
- Classes, variables and components
- Groups
- Props
- The
layoutblock
Settings
A setting is key: value on its own line, usually at the top of the file.
| setting | values | default |
|---|---|---|
title | text, with inline markup | none |
subtitle | muted line under the title | none |
footer | a | b | c: a strip under the diagram, items spread edge to edge (plugin) | none |
theme | paper midnight blueprint mono pastel terminal sepia frost contrast ocean ember dusk, or your own (auto in the browser) | paper |
direction | right down left up; Mermaid's LR RL TB TD BT work too | right |
curve | smooth orthogonal straight | smooth |
gap | space between nodes in a rank, px | 36 |
rank-gap | space between ranks, px | 72 (96 with groups) |
max-width | fit the diagram into this width, px: ranks wrap into rows (more) | none |
padding | space around the diagram, px | 24 |
shape | default node shape | rounded |
font | font family or fallback list, e.g. Inter, Lora, Georgia, serif (fonts) | theme font |
font-size | px | theme size |
background | colour, or none for transparent | theme background |
grid | true, false or a colour | theme default |
shadow | true / false | theme default |
radius | node corner radius, px | theme default |
stroke-width | node border width, px | theme default |
edge-color | default colour of every edge, sequence message and Gantt arrow | theme edge colour |
edge-width | their default width, px | theme default |
accent | colour of `code`, chips and bars in cards | theme accent |
panels | row column grid: how panels line up next to the graph | row |
panel-gap | space between the graph and panels, px | 48 |
wrap | wrap node labels wider than this, px | none |
legend | .class Label | color Label | --> Label: a key under the diagram (plugin) | none |
An unknown setting gives a warning that suggests the closest known one (titel → title). The setting is kept, so typos stay visible.
Nodes
id ["Label"] [.class ...] [[props]]web
api "API Gateway"
.store [amber]
db "Orders DB" .store [cylinder]idis letters, digits,_and-. It is what edges refer to.- The label defaults to the id. Labels use
"double"or'single'quotes.\ninside a label makes a line break. - Declaring the same id twice merges the props. The later value wins.
Several nodes can go on one line, separated by commas:
a "Alpha", b "Beta", c "Gamma" [green]A node does not have to be declared. Using an id in an edge creates it.
Edges
a -> b [-> c ...] [: label] [.class ...] [[props]]user -> web -> api
api -> db: SQL
api -> cache: read-through [dashed]
api -> audit: [flow]Arrows
| arrow | line | heads |
|---|---|---|
-> | solid | at the end |
--> | dashed | at the end |
..> | dotted | at the end |
=> ==> | thick | at the end |
<-> | solid | at both ends |
-- - | solid | none |
Props can override all of these: style, width, head and tail.
Labels and props after a colon
Edge labels, classes and props always go after a colon. The colon keeps them apart from inline node declarations (see the next section).
a -> b: add item
.warn [red]
a -> b: "label: with a colon"
a -> b: retry .warn [width: 2]
a -> b: [dotted]A label without quotes runs to the first class or [. Use quotes when the label contains :, [, . at the start of a word, or leading spaces.
Inline nodes
A label, classes or props written directly after an id in an edge declare that node, exactly like a node statement:
web "Web" [blue] -> api "API" -> db "DB" [cylinder]: SQLHere [cylinder] belongs to db and SQL labels every edge on the line.
A quoted string after the last node without a colon is an error. The message shows the fix: (edge labels go after a colon: a -> b: "label").
In the same way, a -> b [dashed] dashes the border of b, not the edge. Write a -> b: [dashed], or put style: dashed on the next line. An edge-only prop on a node, like [thick], gives a warning that says so.
Chains and fan-out
a -> b -> c creates two edges. Commas fan out:
web, mobile -> api // two edges
api -> users, orders, cart // three edgesThe label, classes and props after the colon apply to every edge created by the statement.
Repeated edges
Two edges between the same nodes are both drawn. In the layout block the second one is addressed as a->b#2.
Classes
A class is a named set of props.
.svc [blue, rounded]
.store [amber, cylinder]
.async [dashed, flow]
orders "Orders" .svc
db .store
orders -> queue: publish .async- A class can apply to nodes, edges and groups. Props that do not fit the target are ignored.
- Several classes apply left to right. Props written on the element override all classes.
- An unknown class gives a warning.
A class can build on other classes. The new class gets their props, then its own:
.svc [blue, rounded]
.primary .svc [bold, stroke-width: 2]
.legacy .svc [gray, dashed]
api "API" .primary
old "Old API" .legacy
api -> oldVariables
A variable holds a value you use in many places. Define it with $name: value, then write $name in labels, props, settings and panel bodies.
$brand: violet
$db: "Postgres 16"
title: Shop
accent: $brand
.svc [$brand]
api "API" .svc -> orders-db "$db" [cylinder]- Define a variable before you use it. A later definition replaces the value for the lines after it.
- Write
${name}when letters follow directly:${id}_db. $$is a literal$. A$before a digit stays as it is:"costs $5".- An unknown variable gives a warning and the text stays unchanged.
Components
A component stamps out the same lines many times. Define it with def, then call it like a function:
$db: Postgres
.svc [blue, rounded]
.store [amber, cylinder]
def service(id, label, lang = Go) {
$id "$label" .svc [sub: $lang]
${id}_db "$db" .store
$id -> ${id}_db
}
service(orders, "Orders")
service(payments, "Payments", Rust)
service(search, "Search", lang: Kotlin)
gateway "Gateway" -> orders, payments, search- Parameters are variables inside the body.
name = valuegives a default. - Arguments go by position or by name (
lang: Rust). Quote an argument that holds a comma. - A body can hold nodes, edges, groups, cards and calls to other components.
- File variables are fixed when the component is defined, so a component works the same after it is imported.
defis top-level only. Errors inside a call point at the call line.- The visual editor cannot edit a generated line in place. A prop you change there is added as a new line for that node.
Groups
group id ["Label"] [.class ...] [[props]] {
members
}group backend "Backend" [blue] {
api "API"
worker "Worker"
group data "Data" {
db [cylinder]
}
}
group edge "Edge" { cdn, waf }- The id is optional:
group "Order service" {gets the idorder-service. - Nodes declared or referenced inside the braces become members.
- Groups nest.
- Edges can be written inside or outside a group. Where an edge is written does not change membership of nodes that are already in a group.
- Edges can not point at a group.
Props
Props are a comma-separated list in square brackets:
[key: value, key: "quoted value", flag]A key without a value means true. Values can be bare words, numbers, colours or quoted strings.
A bare value that only fits one key stands for that key:
| written | means |
|---|---|
[blue] | [blue] |
[cylinder] | [shape: cylinder] |
[orthogonal] | [curve: orthogonal] |
[dashed], [dotted] | a dashed or dotted line or border |
[thick] | a line twice as wide (edges) |
So db "Postgres" [cylinder, amber, bold] needs no keys at all.
One prop per line
Props can also go on their own lines, indented below the statement. This reads better than a long [...] list:
.svc
color: blue
shape: rounded
group payments "Payments" {
color: green
pay "Payment API" .svc
sub: Rust
tooltip: "charges, refunds, payouts"
ledger [cylinder]
}
pay -> ledger: write
style: dashed
caption: append only- A
key: valueline indented deeper than a node, edge, class or group line belongs to that statement. - Inside a group, a
key: valueline at the members' indent belongs to the group. - The value runs to the end of the line, so commas need no quotes.
- Both styles can be mixed. A line below wins over the same key in
[...]. - The visual editor keeps the style: it edits the prop line, and adds new props as lines too.
Colours
Any colour prop accepts:
- a CSS colour:
#2563eb,rgb(…),tomato - a palette name:
blue,amber, … The theme picks a fitting shade. - a palette name with a shade:
blue-600,slate-100(50, 100 … 900, 950)
color
color sets fill, border and text colour together. It is the quickest way to colour something. Write it bare, [blue], or as [color: blue].
Palette names: slate gray red orange amber lime green tealcyan blue indigo purple pink. The theme picks shades that fit, so they look right in light and dark themes.
Any CSS colour works too, bare or with the key: [#e11d48], [#e11d4880], [rgb(225, 29, 72)], [hsl(350 80% 50%)], [tomato]. Yuhwa derives the fill, border and text from it.
tone is the old name of color and still works.
Node props
| prop | values |
|---|---|
shape | rounded box pill circle ellipse diamond hexagon cylinder parallelogram document note text |
color | palette name or any CSS colour: fill, border and label in one |
fill | colour |
stroke | border colour |
text | label colour |
sub | second, smaller line of text |
sub-color | colour of the sub line |
icon | emoji or short text shown before the label |
border / stroke-width | border width, px |
border-style | solid dashed dotted |
dashed | shorthand for border-style: dashed |
radius | corner radius, px |
bold / italic | flags |
font | label font: sans serif mono or font names (quote a list: font: "Lora, serif") |
font-size / font-weight | numbers |
shadow | true / false |
opacity | 0 to 1 |
width / height | box size, px |
max-width | wrap the label at this width, px (overrides the wrap setting) |
link | URL; the node becomes a link in the SVG. Only http(s), mailto, #anchor and relative links render |
tooltip | text shown on hover |
meta | muted text at the top right of a card |
caps | small-caps header label |
mono | false sets a card body in the diagram font |
body-size / body-weight | card body font size, px, and weight (cards) |
body-color | card body text colour; defaults to text |
line-height | card body row height as a multiple of body-size, default 1.75 |
frame | browser <url>, window <title> or terminal <path>: window chrome around a card (plugin) |
below / above | node id: place this node under or over that one (placement) |
right-of / left-of | node id: place this node to the right or left of that one |
rank | node id: put this node in the same rank as that one |
shape: text draws only the label, with no box. Use it for annotations.
Edge props
| prop | values |
|---|---|
style | solid dashed dotted |
width | line width, px |
color | line and label colour: palette name or any CSS colour |
stroke | line colour only |
curve | smooth orthogonal straight |
head | arrow open dot diamond bar none |
tail | same values as head, for the start |
flow / animate | animated dashes along the edge |
opacity | 0 to 1 |
text | label text colour (label-color works too) |
font | label font: sans serif mono or font names |
font-size | label font size, px |
font-weight | label weight: 400, 600, 700 ... |
italic | italic label |
label-bg | label background colour |
exit / from-side | top right bottom left |
enter / to-side | top right bottom left |
constraint | false keeps the edge from affecting the layout |
length | ranks the edge spans, 1 to 12 (default 1): pushes the target further away |
caption | small muted text under the label |
rotate | true turns the label to run vertically |
The curve: setting picks the default for the whole diagram. An edge's own curve overrides it, so one diagram can mix all three. A class works too:
direction: right
curve: smooth
.wire [orthogonal, dashed]
api "API" -> db "DB" [shape: cylinder]: [orthogonal]
api -> cache "Cache": [straight]
api -> queue "Queue": .wire
queue -> worker "Worker"Use constraint: false for feedback edges that would pull the layout apart.
Group props
| prop | values |
|---|---|
color | palette name or any CSS colour |
fill | background colour |
stroke | border colour |
text | title colour |
font | title font: sans serif mono |
font-size | title font size, px |
font-weight | title weight, default 600 |
italic | italic title |
border-style | solid dashed dotted |
dashed | shorthand for border-style: dashed |
meta | muted text at the top right |
caps | small-caps title |
A group is as wide as its label and meta need. When other nodes leave too little room beside the group, the label wraps onto more lines instead.
Text
Every element takes the same five text props: text (colour), font, font-size, font-weight and italic. They style a node's label, an edge's label, a group's title and a panel's title. On a panel, font-size also scales the text inside it.
font takes the same values as the font setting: sans, serif, mono or font names. Quote a list, since commas separate props: [font: "Lora, serif"].
To style only part of a text, wrap it in a span: {keys | text}. The keys are color, size, weight, font and italic, separated by commas. A span's font takes one name: {font: mono | code}. A bare colour sets the colour, and a bare bold or italic sets that flag. Spans work in every text: labels, sub, edge labels and captions, group and panel titles, card bodies and panel items.
| span | result |
|---|---|
{color: red | text} | coloured text |
{size: 18 | text} | bigger text, px |
{weight: 700 | text} | heavier text |
{italic | text} | italic text |
{font: mono | text} | monospace text |
{red, bold, size: 18 | text} | all at once, short form |
{red: text} | coloured text, as before |
The other inline markup (**bold**, *muted*, [[chip]] ...) works in these texts too.
direction: right
api "{size: 18, weight: 800 | API} {font: mono | v2}" [sub: "{green | ●} healthy", italic]
db "Orders" [shape: cylinder, font: serif, font-size: 16, font-weight: 700, text: indigo]
group back "Backend" [font-size: 14, font-weight: 800, text: teal] {
api
db
}
api -> db: "{bold | writes}, {italic | async}" [font-size: 13, text: orange]Cards
A node with a { } body becomes a card: a header with the label, a divider, and monospace lines below. A body opens with { at the end of the node line and closes with a line that is only }.
theme: terminal
checks "checks" [meta: 42s, caps] {
✓ typecheck || [[green: pass]]
✓ tests || [[green: 128]]
*skipped: e2e*
---
bars: 3 5 4 6 8 7 9
}
release "release" [meta: v0.1.0, caps] {
| type | bump |
|-------|-------|
| feat | minor |
| fix | patch |
---
~~manual tagging~~
}
checks -> release: green
caption: on mainBody lines:
| line | result |
|---|---|
| text | a line of text |
left || right | right is aligned to the right edge |
--- | a divider |
| empty line | a small gap |
bars: 3 5 8 | a bar chart; bars green: … picks a colour |
spark: 3 5 4 8 | a sparkline with a soft area |
progress: 72% tests | a labelled progress bar; 9/12 deploys works too |
stat: 99.9% uptime | 42ms p95 | big numbers with labels, side by side |
| a | b | | a table row; a |---| row makes the row above a header |
bars, spark, progress, stat and tables come from the built-in plugins. Each takes an optional colour after its keyword.
Inline markup inside a line:
| markup | result |
|---|---|
**bold** | bold |
*muted* | muted colour |
~~text~~ | struck through |
`code` | accent colour |
[[chip]] / [[green: chip]] | a small outlined chip |
{red: text} / {#f97316: text} | coloured text |
{size: 18, weight: 700 | text} | styled text (text) |
meta puts muted text at the top right, caps turns the header into small caps. With shape: text the card has no frame.
The header and the body are styled apart. font-size, font-weight and text set the header label. body-size, body-weight, body-color and line-height set the body lines; inline colours still win over body-color.
theme: midnight
laptop "~/shop" [frame: window your laptop, font-size: 18, body-size: 15, body-weight: 500, body-color: #e2e8f0, line-height: 1.6] {
$ lf setup vps --host <server-ip>
{green: ✓} docker · ufw · fail2ban · traefik
$ lf deploy
{green: ✓} live → https://shop.example.com
}Placement
A placement prop puts one node next to another. The value is the other node's id.
firewall -> traefik -> app
journal [below: traefik]
cron [right-of: app]| prop | where the node goes |
|---|---|
below | under the other node |
above | over the other node |
right-of | to the right of the other node |
left-of | to the left of the other node |
rank | in the same rank (column or row) as the other |
The directions are on screen. They do not turn with direction. A placement draws no edge. It replaces the old trick of an invisible edge (a -> b: [opacity: 0]). Placement works inside groups, and across them.
A node takes one placement prop. An unknown id, a group id, the node's own id and a loop of placements each give a warning with the line. Edges win over placement. When an edge runs the other way, the placement is dropped with a warning.
Fitting a narrow column
The max-width setting keeps a wide diagram inside a column. When the diagram is wider than the limit, its ranks wrap into rows, like words in a paragraph. Each row starts at the left. Edges to the next row run through the gap between the rows.
max-width: 640
commit -> lint -> test -> build -> scan -> stage -> e2e -> prodA diagram that already fits does not change. A group is never split: all its ranks stay in one row. Only direction: right and direction: left wrap. A down or up diagram grows in height, so it is left as it is. A single rank or group wider than the limit stays wider. Pinned nodes (the layout block) turn wrapping off.
The layout block
The visual editor writes manual positions into a layout block at the end of the file. It can also be written by hand.
a -> b: HTTPS
b -> c
layout {
a at 40 40
b at 260 40 size 160 64
c at 40 200
a->b label 0 -14
b->c via 340 224 ports bottom right
}| line | meaning |
|---|---|
id at X Y | pin a node or group at this top-left position |
id ... size W H | fixed size |
a->b via X Y [X Y ...] | waypoints the edge passes through |
a->b ... ports S S | start and end sides: top right bottom left (auto to let the router pick) |
a->b ... label DX DY | move the label from its default place |
a->b#2 ... | the second edge from a to b, when there are several |
rank a b c | keep these nodes in the same rank (row or column) |
panel at X Y | pin a panel at this top-left position (panels take no size) |
panel:part D | nudge one part of a panel along the axis it moves on; the panel kind names its parts (see git) |
panel:part DX DY | nudge a part that moves freely in both directions |
Nodes without a position are still laid out automatically around the pinned ones. Delete the block to return to full auto-layout.
rank lines are layout hints, not positions: the nodes still get placed automatically, but share one rank. Nothing in a rank set is pinned.
Panels, imports and exports
Sequence diagrams, timelines, charts and git histories can sit next to the graph in the same file. A diagram can be split over files:
import "./styles.yu" // everything the file exports
import { api, .svc as .service } from "./x" // only some things, renamed
import { service, $brand } from "./kit" // components and variables
export api, data, .svc // what importers may take
export db "Orders DB" .store // export in front of a declaration
export $brand: violet // ... or a variable
export def service(id) { ... } // ... or a componentSee Combining diagrams.
Other input formats
Every API and CLI command also accepts JSON and Mermaid flowcharts. See From Mermaid or JSON. For the look of each theme, see Themes and styling.