Flowchart
The graph is the heart of yuhwa: nodes, edges between them and groups around them. The layout is automatic, so you write what is connected and yuhwa decides where it goes.
direction: down
start "Start" [pill, green] -> form "Fill in form" -> valid "Valid?" [diamond, amber]
valid -> save "Save order": yes
valid -> form: no [dashed, constraint: false]
save -> mail "Send receipt" [document] -> done "Done" [pill, green]This page is a tour with examples. Syntax is the full reference for nodes, edges, groups, classes and every prop.
Nodes and edges
A node is an id with an optional label and props. An edge is two ids and an arrow. Using an id in an edge creates the node, so the shortest diagram is one line:
web -> api -> dbLabels go in quotes, edge labels after a colon, props in brackets:
web "Storefront" [blue] -> api "Orders API" [blue]: place order
api -> db "Postgres" [cylinder, amber]: SQL
api -> cache "Redis" [cylinder]: read-through [dashed]Direction
direction sets where the graph grows: right (default), down, left or up. Mermaid's LR, TB, TD, RL and BT work too.
direction: down
idea "Idea" -> spec "Spec" -> build "Build" -> ship "Ship" [green]Shapes
A shape name works as a flag: [diamond] is short for [shape: diamond]. shape: as a setting changes the default for every node.
rounded "rounded" -- box "box" [box] -- pill "pill" [pill] -- circle "circle" [circle]
ellipse "ellipse" [ellipse] -- diamond "diamond" [diamond] -- hexagon "hexagon" [hexagon] -- cylinder "cylinder" [cylinder]
para "parallelogram" [parallelogram] -- document "document" [document] -- note "note" [note] -- text "text" [text]Aliases cover the names other tools use: rect, stadium, decision, database, io, sticky and more.
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 |
a "A" -> b "B": calls
a --> c "C": replies
a ..> d "D": async
a => e "E": hot path
a <-> f "F": sync
a -- g "G": linked
b -> h "H": events [flow]
c -> h: [head: diamond, tail: dot]flow animates the dashes. head and tail take arrow, open, dot, diamond, bar or none.
Groups
A group draws a box around its nodes. Groups nest.
title: Shop
direction: right
user "Customer" [circle, purple]
group edge "Edge" [dashed] {
cdn "CDN"
}
group app "App" [blue] {
web "Web"
api "API"
worker "Worker"
}
group data "Data" [amber] {
db "Postgres" [cylinder]
queue "Queue" [pill]
}
user -> cdn -> web -> api
api -> db: SQL
api -> queue: publish
queue -> worker: consume [flow]
worker -> dbCards and frames
A node with a { } body is a card: a header and monospace lines with dividers, aligned columns, tables, bars and sparklines. frame draws browser, window or terminal chrome around it. See cards for every body line.
theme: dusk
shop "Shop" [frame: browser shop.example.com] {
**Cart** || 3 items
---
progress: 2/3 checkout
spark: 3 5 4 8 7 9
}
cli "Deploy" [frame: terminal ~/shop] {
yuhwa render shop.yu
`✓ shop.svg`
}
shop -> cli: [dashed]Examples
State machine
States as pills, transitions as labelled edges. constraint: false keeps a backwards edge from pulling the layout apart.
title: Order states
new "New" [pill] -> paid "Paid" [pill]: pay
paid -> shipped "Shipped" [pill]: ship
shipped -> done "Delivered" [pill, green]: deliver
new, paid -> cancelled "Cancelled" [pill, red]: cancel [dashed]
shipped -> paid: return [dotted, constraint: false]Decision tree
direction: down
theme: pastel
q1 "Is it broken?" [diamond] -> q2 "Did you touch it?" [diamond]: yes
q1 -> ok "Leave it" [pill, green]: no
q2 -> fix "Fix it" [pill, amber]: yes
q2 -> log "Read the logs" [pill, blue]: noData model
Cards with tables work as entity boxes; edge heads mark the cardinality.
direction: right
user "users" [caps] {
| id | uuid |
| email | text |
}
order "orders" [caps] {
| id | uuid |
| user_id | uuid |
| total | numeric |
}
user -> order: 1..n [head: open, tail: bar]Annotated pipeline
A note joins the pipeline with a dotted, unconstrained edge, so it sits next to the step it explains.
theme: mono
curve: straight
a "Input" -> b "Parse" -> c "Layout" -> d "Render" -> e "SVG" [document]
note "same input,\nsame SVG" [note]
d -- note: [dotted, constraint: false]More in the examples: web apps, deploys, team ownership and status boards.