Cards and zones
Cards are the boxes of a diagram; zones group them. Both take a title, classes and a few attributes.
Cards
diagram(dir="right")
card#plain Plain card
card#typed.t2 Typed card
| first line
| 192.168.1.0/24 office
card#tagged.t1(tag="Owner: ops") With a tag
| the chip shows the tag| Write | Effect |
|---|---|
card#id Title | a card; the text after the tag is its title |
| text | a content line, indented under the card. A line that starts with an IPv4 address or a CIDR block
shows it in monospace. (Preview) |.pill 8080 · http: the line takes its classes; the theme's
.pill draws it as a pill tinted with the card's colour |
.type | the card's type: its colour and badge come from CSS |
tag="…" | the text of the card's chip (an owner, a module, a port) |
label="…" (preview) | the card's category, above its name; by default the type's --label; label="" shows none. See Rich cards |
icon="…", href="…" | an icon before the title, a link: see Icons and links |
at="x,y" | a pinned position: see Layout |
Keep titles short (under about 30 characters): a long title widens the card, while long lines wrap. Three or four lines per card read best.
A card without lines has its title centred; with lines, the title stays on the left above them. In a column of cards (a
wrap="1" zone, a stack) where others have lines, a card without lines keeps the column's alignment.
Piles of cards (preview)
diagram(dir="right")
card#lb.t3(tag="ALB") Load balancer
to(api) HTTPS
cards#api.t2(count="4" tag="ECS") api
| 4 tasks
to(db) 5432
cards#jobs.t2 workers
| autoscaled
to(db)
card#db.t1(tag="RDS") orderscards instead of card draws a pile: several instances of one thing (the tasks of a service, the
machines of a group). It is a card in every respect: lines, arrows, classes, chip. count="4" says how many: up to
three cards are drawn, and a ×4 badge sits on the pile's bottom-right corner, at the same place in every look.
Without count, three cards and no badge. The cards behind belong to the card's box: arrows end on them and the top
card keeps the width of its neighbours.
zones instead of zone does the same for a group: several instances of one group (the clusters of a
fleet, the replicas of a region) drawn as a pile of frames. What the zone holds is drawn once, in the frame on top;
count reads as on cards.
Nodes
diagram(dir="right" look="header")
node#user(icon="user") Customer
| web and mobile
to(api) HTTPS
card#api.service(tag="ECS") API
| 3 tasks
to(db cache)
node#db.db(icon="database") Orders
| PostgreSQL 16
| Multi-AZ, encrypted
node#cache.cache(icon="zap") Cache
| Redis 7/* the card keeps its look; the nodes are drawn the same in every look */
.service { --c: #3E6FC4; --label: "Service"; }
.db { --c: #D9892B; }
.cache { --c: #C94A44; }node instead of card draws a thing by its icon rather than by a box: the icon on the left, the name
beside it, the lines under the name; no frame, no band. Nodes and cards mix in one diagram: the diagram's look and a type's
--look do not apply to a node. Every node's icon has the same size (32 px, --icon-size), centred on
the height of its text and coloured by its type; arrows end in the middle of the icon. A node takes what a card takes (classes,
icon, href, lines, arrows, at, markers), except tag and label:
it has no chip nor category.
Zones
diagram(dir="down")
zone#site.cloud Datacenter
zone#dmz.dmz DMZ
card#web Web
card#mail Mail
zone#lan.lan LAN
card#files Files
card#print PrintersA zone encloses everything indented below it, with a margin and room for its title. Zones nest. A zone gives its accent
colour to the untyped cards it contains, and an empty zone keeps a visible frame. With at="x,y", a zone can also
take an imposed size="w,h". (Preview) tag="…" on a zone adds a pill after its title
(zone#pods(tag="172.30.0.0/16") Pods), as on a card. .tag-left and .tag-right on a card or
a zone put its badge before or after the name. A stylesheet may set a zone's title at the bottom
(zone.svc > .title { top: auto; bottom: 12px }): the room for it is then kept below the cards.
Title of the diagram (preview)
diagram
title Kubernetes application architecture
|.pill namespace mon_namespace
A title, written once directly under diagram, is drawn above the drawing on the left; each of its
| lines is a subtitle line under it, each |.pill line a pill on the right of the same line. The title widens the image if needed and never moves a card.
See the Kubernetes example in Layout.
Notes, chips and boxes
The theme provides secondary cards for annotations, and a frameless zone for captions:
diagram(dir="right")
card#app.t2 Application
| v2.4
to(v10 v20)
card#todo.note To migrate
| before Q3
to(app).link
zone#vlans.bare Uplinks / VLAN
card#v10.chip VLAN 10
card#v20.chip VLAN 20| Class | On | Rendering |
|---|---|---|
.note | card | annotation: dashed border, tinted background, centred text, no badge |
.chip | card | a rounded pill on one line |
.info | card | a small, discreet box |
.bare | zone | no frame; the title becomes a caption below, centred and in italics; without a title, nothing is drawn |
.wide (preview) | card | spans the width of its group, like a network or a bus bar; its arrows drop straight to it and end in a dot |
.wide (preview) | zone | spans the width of its group too; its cards, on one row, share that width |
.col-name (preview) | card, zone | a column: nodes of one .col-… class line up across the direction, from one zone to another (pods and services over the machine that hosts them) |
They combine with your own types, and keep their plain style whatever the card look of the diagram. Use the .link
arrow style to attach a note to a card.
Built-in types
The default theme ships a few network-flavoured types, handy for quick sketches: .t0 (red, "T0"),
.t1 (orange), .t2 (blue), .t3 (grey) for cards, and .cloud, .dmz,
.lan for zones. For anything else, define your own in a few lines of CSS.
