Arrows
An arrow is written inside the card it leaves: to(target). Its classes style it, its text labels it.
Writing an arrow
card#api API
to(db) //- api → db
to(queue).dashed events //- styled, with a label
card#db Database
card#queue Queue
The target is the #id of a card. An unknown target is an error, with a suggestion when the id is close to an
existing one. Arrows may go backwards, form cycles, or link a card to several others.
Styles
diagram(dir="right")
card#a1 A
to(b1).dashed dashed
card#b1 B
card#a2 A
to(b2).dotted dotted
card#b2 B
card#a3 A
to(b3).flow flow
card#b3 B
card#a7 A
to(b7).pulse pulse
card#b7 B
card#a4 A
to(b4).both both
card#b4 B
card#a5 A
to(b5).dot.nohead dot.nohead
card#b5 B
card#a6 A
to(b6).link link
card#b6 B| Class | Effect |
|---|---|
.dashed, .dotted | dashed or dotted line |
.thick | thicker line |
.flow | dashes running towards the head |
.pulse | a glowing dot running from the source to the head |
.both | a head at both ends |
.nohead | no head |
.dot | a dot at the start |
.link | dotted, no head: attaches a note to a card |
.wan, .secure | colour examples of the default theme (red and thicker, green) |
Classes combine (to(b).dashed.both). Your own classes colour arrows through CSS:
.edge.important { color: #E8590C; }. When the direction or the kind of an arrow matters, give it a line style too,
not only a colour, so it reads in black and white.
Arrows in motion (preview)
.flow and .pulse loop for as long as the diagram is shown. Every dot runs at the same speed, so the
dots of all arrows leave together and a long arrow takes longer. They play in the HTML (stopped for a reader who asks for
less motion), in GIF, APNG and animated WebP, and in the SVG when you ask for it with --motion. A still image
draws them as plain solid lines. See Animated flows.
.edge.orders { --pulse-color: #E8590C; --pulse-size: 7px; --pulse-speed: 200px; }
.edge.flow { --flow-speed: 30px; } /* px per second */
Several targets
diagram(dir="down")
card#lb Load balancer
to(w1 w2 w3)
card#w1 Worker 1
card#w2 Worker 2
card#w3 Worker 3to(w1 w2 w3) creates one arrow per target, all with the same classes and label (a label is therefore repeated on
each arrow).
Shared trunk
diagram(dir="down")
card#ceo CEO
to(cto cfo coo join="trunk")
card#cto CTO
card#cfo CFO
card#coo COOWith join="trunk", the arrows of one to(…) leave the same point and share a trunk before branching, the
way organisation charts are drawn. Each target still has its own arrow, with its own id and animation marker.
(preview) Arrows from one card to several cards of the next row, alike (same classes, no label or the same label), are drawn this way without asking when the side is crowded or they would cross a row of cards (a fork); a shared label is written once. When several cards each link to the same cards of the next row, every one to every one, their arrows share one bar between the rows (a bus) instead of crossing. Junctions are rounded bends into the trunk. Where two lines still cross, the horizontal one is cut on each side of the other.
(preview) Any other name joins arrows into one card: arrows to the same card that carry the same
join="http", written under different cards, meet before it and end on one line with a single head (the HTTP
calls of two frontends to one backend, in the Kubernetes example of Layout). A name that no other
arrow to that card carries is reported and ignored. Their label names the whole flow: it sits on the part the arrows
share, just before the card.
A line without a head (.nohead, .link, a head shown as a dot) runs right up to the card.
Tunnels (preview)
diagram(dir="right")
zone#paris Paris site
card#app(icon="skemo-container") Orders app
to(db tunnel="vpn") SQL
to(s3 tunnel="vpn") Backups
to(web) Health
card#gw-a(icon="skemo-vpn") VPN gateway
tunnel#vpn(gw-b) IPsec
zone#lyon Lyon site
card#gw-b(icon="skemo-vpn") VPN gateway
card#db(icon="skemo-server") Database
card#s3(icon="skemo-object-storage") Object storage
card#web(icon="skemo-web") Status pagetunnel joins two cards with a tube: a VPN between two gateways, a link between two sites. It is written like an
arrow, inside one of the two cards (tunnel#vpn(gw-b) IPsec), with an id, classes, a label and markers, but no
head. An arrow passes through it when it names it, to(db tunnel="vpn"): it runs into the near end, along the
tunnel on a lane of its own, and out of the far end to its target, as one line hidden inside the two cards. The tube widens by
a lane for each arrow; arrows that do not name it (here the health check) go their own way.
Arrows outside the layout (preview)
diagram(dir="down")
card#client Client
to(svc)
card#dns CoreDNS
card#svc Service
to(p1 p2)
card#p1 Pod 1
to(dns constraint="false").dashed
card#p2 Pod 2
to(dns constraint="false").dashedconstraint="false" draws and routes an arrow without letting it shape the layout: its target is not pushed a row
further. Use it for cross links (service discovery, monitoring, callbacks) that would otherwise turn the diagram into a long
chain. Here CoreDNS stays beside the pods instead of below them.
Classes from the endpoints
diagram(dir="right")
card#u1.uplink Uplink A
to(core)
card#u2.uplink Uplink B
to(core)
card#core.t1 Core
to(srv)
card#srv.t2 Servers.uplink { --c: #7B5CC4; --label: "UPLINK"; }
/* every arrow leaving an uplink card takes its colour */
.edge.from-uplink { color: #7B5CC4; }Every arrow automatically receives the classes from-<type> and to-<type> of the cards it
joins, so one CSS rule can colour all arrows leaving or entering a type.
Sides, waypoints, ids
| Attribute | Effect |
|---|---|
side="right-top" | attachment side at the start and at the end, among top bottom
left right. One half may stay empty: side="-top" |
via="x,y x,y" | waypoints the route passes through, in order |
href="…" | the arrow is a link (SVG and HTML) |
to#id(…) | an explicit id; by default an arrow is called source->target
(then #2, #3 for duplicates) |
See Layout and positions for when to use side and via.
Routing
Every arrow is routed with right angles, around the cards and around the zones that contain neither of its ends. Bends sit in the middle of the free corridor, and arrows that share a side are spread apart. You never draw a route yourself.
