Skip to content

Themes and styling ​

Themes ​

Pick a theme with the theme: setting or --theme on the command line. The command line wins. In the browser, theme: auto (or no theme) follows the reader's colour scheme: paper in light mode, midnight in dark mode.

yuhwa ships twelve themes, shown below. You can also define your own.

A theme belongs to the file that sets it: importing a file does not take its theme. For one theme across many files, put export theme: midnight in a shared kit file and import that. See settings across files.

paper ​

The default. Warm off-white with soft tones.

midnight ​

Dark, close to GitHub's dark mode.

blueprint ​

White lines on blueprint blue, monospace text, a grid.

mono ​

Black and white. Good for print and for slides with their own colours.

pastel ​

Soft fills, borderless boxes, round corners.

sepia ​

Warm paper and a serif face, like a printed book.

frost ​

Cool blue-grey and flat boxes with no shadow.

contrast ​

Black on white with heavier lines. Easy to read on a projector or in print.

ocean ​

Dark navy with cyan lines.

ember ​

Warm charcoal with orange lines.

dusk ​

Deep violet with pink lines.

terminal ​

Monospace on near-black with violet edges. Made for cards and infographics.

>landfallEdit
yuhwa
title: >landfall
subtitle: bare server to HTTPS in two commands
theme: terminal
direction: right
rank-gap: 120

laptop "~/shop" [meta: your laptop] {
  $ `lf setup vps --host <server-ip>`
  {green: ✓} docker · ufw · fail2ban · traefik
  $ `lf server domain vps example.com`
  {green: ✓} new sites get *<site>.example.com*
  $ `lf deploy`
  *→ compose.yaml: web, db*
  {green: ✓} built web · health check passed
  {green: ✓} live → **https://shop.example.com**
}

group vps "vps" [caps] {
  meta: Ubuntu 24.04 · no agent installed
  traefik "Traefik" [meta: $ lf certs] {
    Let's Encrypt · HTTP/3 · :443
  }
  shop "shop.example.com" [meta: compose] {
    [[web :3000]] [[db postgres]] || `$ lf volume backup`
    backup **daily** → nas
  }
  blog "blog.example.com" [meta: static] {
    [[nginx:alpine]] login in front || `$ lf auth`
  }
  api "api.example.com" [meta: Dockerfile] {
    [[app :8080]] releases {green: ●●●●} || `$ lf rollback`
  }
  journal "journal" [meta: every change recorded, caps] {
    *#5 14:41* env shop STRIPE_KEY=… || {green: ↺}
    *#4 14:38* domains shop +www   || {green: ↺}
    *#3 14:30* deploy shop        || {green: ↺}
    ---
    `$ lf history · lf undo`
  }
}

group net "the internet" [caps] {
  d1 "🔒 shop.example.com"
    sub: your shop, live
  d2 "🔒 blog.example.com"
    sub: static files, nginx
  d3 "🔒 api.example.com/health"
    sub: {ok: true}
}

dns "dns at your registrar" [caps, dashed] {
  A  example.com   → <server-ip>
  A  *.example.com → <server-ip>
  ---
  `$ lf domains · lf check`
}

traffic "last 24h" [meta: $ lf traffic, caps] {
  | site | requests | 5xx | p95   |
  |------|----------|-----|-------|
  | shop | 12.4k    | 0   | 84 ms |
  | blog | 3.1k     | 0   | 12 ms |
  | api  | 48.0k    | 2   | 41 ms |
  bars: 2 3 2 4 6 8 9 8 7 9 10 9 8 7 6 5
  cpu **12%** · mem **41%** · disk **38%**
}

stop "what you stop doing" [shape: text, caps] {
  ~~hand-writing nginx configs and certbot cron jobs~~
  ~~paying a PaaS for a side project~~
  ~~running a daemon you can't read~~
}

laptop -> traefik: ssh
  caption: one bash script per command
laptop -> journal: [dotted, head: dot]
traefik -> shop, blog, api
shop -> d1: HTTPS
blog -> d2
api -> d3
d3 -> dns: [dotted, head: none]
d1 -> traffic: [dotted, head: none]

Your own theme ​

Define a theme in the file with a theme block, then pick it like any other:

CheckoutEdit
yuhwa
theme brand {
  base: paper
  background: #fffaf0
  node-fill: amber
  node-stroke: orange
  edge-color: orange
  title-color: #7c2d12
  radius: 4
}

theme: brand
title: Checkout
cart "Cart" -> pay "Payment" -> done "Done" [green]

Short themes fit on one line:

yuhwa diagramEdit
yuhwa
theme brand [base: midnight, accent: orange, edge-color: orange]
theme: brand
a "Build" -> b "Ship"

A theme starts from its base, paper unless set, and changes only the keys you give. The base can be a built-in theme or another theme of your own. A theme named like a built-in one (theme midnight [radius: 0]) adjusts that theme in place.

Colours take a palette name (orange), which picks a shade that suits the role, or any CSS colour. yuhwa check warns on unknown keys and colours.

keysets
basethe theme to start from (default paper)
darktrue for a dark theme: palette colours pick dark shades
backgroundpage colour, or none
fontfont family; mono and sans are shortcuts, a name with "mono" in it switches to monospace
font-sizebase text size in px
node-fill node-stroke node-text node-subbox fill, border, label and second line
group-fill group-stroke group-textgroup background (or none), border and label
group-bordergroup border style: solid, dashed or dotted
edge-color edge-text label-bglines, edge labels, the background behind edge labels
title-colortitle and panel headings
accentcode spans, chips and highlights
radius stroke-width edge-widthcorner radius, box border and line width in px
shadowbox shadow colour, or none
gridbackground grid colour, or none

Sharing a theme ​

Themes travel with imports, like classes. Keep your themes in a kit file and import it wherever you need them:

yuhwa
// brand.yu
theme brand [base: paper, accent: orange, edge-color: orange]
export theme: brand
yuhwa
import "./brand.yu"
a -> b

export theme: brand also makes it the theme of every file that imports the kit. Leave it out to only make brand available. Pick one theme with import { brand } from "./brand.yu".

A panel can use a custom theme too: chart sales [theme: brand] { … }.

From JavaScript ​

To use a theme in every diagram without defining it in each file, register it as a plugin. createTheme builds a theme from the same keys:

ts
import { use, createTheme } from 'yuhwa';

use({
  name: 'brand-theme',
  themes: [createTheme('brand', { base: 'midnight', accent: 'orange', 'edge-color': 'orange' })],
});

theme: brand then works in every diagram that script renders. --theme on the command line also accepts a theme defined in the file: yuhwa render diagram.yu --theme brand.

Tones ​

color sets fill, border and text colour in one prop. Each theme picks the shades, so a palette colour looks right in light and dark themes.

yuhwa diagramyuhwa diagramEdit
yuhwa
direction: right
gap: 16
slate [slate], red [red], orange [orange], amber [amber]
lime [lime], green [green], teal [teal], cyan [cyan]
blue [blue], indigo [indigo], purple [purple], pink [pink]
slate -> red -> orange -> amber
lime -> green -> teal -> cyan
blue -> indigo -> purple -> pink

Shapes ​

yuhwa diagramyuhwa diagramEdit
yuhwa
direction: down
gap: 20
rounded [rounded], box [box], pill [pill], circle [circle]
ellipse [ellipse], diamond [diamond], hexagon [hexagon], cylinder [cylinder]
parallelogram [parallelogram], document [document], note [note], text [shape: text]
rounded -> ellipse -> parallelogram
box -> diamond -> document
pill -> hexagon -> note
circle -> cylinder -> text

Edges ​

yuhwa diagramyuhwa diagramEdit
yuhwa
a -> b: solid
c --> d: dashed
e ..> f: dotted
g => h: thick
i <-> j: both ends
k -> l: animated [flow, blue]
m -> n: heads
  head: diamond
  tail: dot

Classes ​

Define a look once and apply it by name. Props on the element override the class.

yuhwa diagramyuhwa diagramEdit
yuhwa
.svc [blue]
  sub: service
.store [amber, cylinder]
.async [dashed, flow]

api "API" .svc
billing "Billing" .svc [green]
db "Postgres" .store

api -> db
api -> billing: invoice .async

Diagram settings ​

Settings at the top of the file change the whole diagram: curve, gap, rank-gap, padding, font, font-size, background, grid, shadow, radius, stroke-width, shape, subtitle and accent. The settings table has the details.

yuhwa diagramyuhwa diagramEdit
yuhwa
curve: orthogonal
radius: 2
shadow: false
grid: true
font: JetBrains Mono

a "build" -> b "test" -> c "deploy"
b -> d "report": [dotted]

Released under the MIT License.