Styling

Class blocks, stylesheets, and themes — how a site looks.

Two layers control how a site looks: class blocks style individual elements, and a site theme sets the palette every built-in element draws from. Classes always win over theme defaults via the cascade, so you theme broadly and override locally.

§ 1Classes

A class <name> { … } block declares a CSS class. Apply it by listing the name in any block's class field (or a span's). Fields cover text, box, and SVG paint properties; per-mode overrides go in dark { } / light { } sub-blocks.

wcl
class accent {
  color = "var(--wdoc-accent)"
  bold  = true
  dark  { color = "#88c0d0" }
  light { color = "#5e81ac" }
}

// Use the class on a span:
text {
  span "highlighted segment" { class = ["accent"] }
}

§ 2Field groups

GroupFields
Textcolor, background, bold, italic, underline, font_size, font_family, text_align, text_transform, letter_spacing, line_height
Boxpadding, margin, border
SVGfill, stroke, stroke_width, stroke_linejoin, stroke_linecap, opacity
Calloutaccent — sets a callout's accent colour (heading, border, icon) when the class is on a callout
Modesdark { … }, light { … } for prefers-color-scheme overrides

Hyphenated class names may be written bare — class wdoc-series-1 { fill = "#88c0d0" } — or quoted; both are equivalent. This is how you override built-in classes like the chart palette or callout styles. Set sites = [:foo] on a class to scope it to one site in a multi-site document; omit the field and the class applies everywhere.

§ 3Themes

A theme is a complete colour palette plus the rules that map it onto every built-in element — page background, links, headings, code, charts, callouts, tables, inline emphasis. Set theme = :<name> on a site — a symbol naming a theme block. Six built-in palettes ship (nord the default, plus tokyonight, gruvbox, catppuccin, rose, paper), each with co-ordinated dark and light variants and its own typography. theme_toggle = true adds a light/dark toggle button.

wcl
site mysite {
  default_template = :book
  theme            = :tokyonight
  accent           = :cyan
  theme_toggle     = true
}

Independently of the theme, accent = :cyan (or :red/:orange/:yellow/:green/:blue/:purple/:pink) picks the hue used for links and current-chapter highlights. Default is :blue. A custom theme is just a theme block holding a dark and a light palette sub-block.

wcl
theme sunset {
  palette dark {
    bg = "#1a1a2e"  fg = "#e0e0e0"
    blue = "#5e81ac"  green = "#a3be8c"
    // … any of the 18 roles
  }
  palette light {
    bg = "#fdf6e3"  fg = "#073642"
  }
}

site mysite { theme = :sunset  accent = :blue }

§ 4Block reference

A class block: a named CSS class with text, box, SVG, and callout-accent fields, plus per-mode dark / light overrides.

PropertyTypeRequiredDescription
nameidentifieryes
siteslist<symbol>no
colorutf8no
backgroundutf8no
boldboolno
italicboolno
underlineboolno
font_weightutf8no
accentutf8no
font_sizeutf8no
line_heightutf8no
font_familyutf8no
text_alignutf8no
text_transformutf8no
letter_spacingutf8no
paddingutf8no
marginutf8no
borderutf8no
fillutf8no
strokeutf8no
stroke_widthutf8no
stroke_linejoinutf8no
stroke_linecaputf8no
opacityutf8no

Child blocks

SlotAcceptsMultipleDescription
darkdarkno
lightlightno

The dark sub-block of a class: field overrides applied under a prefers-dark colour scheme.

PropertyTypeRequiredDescription
colorutf8no
backgroundutf8no
boldboolno
italicboolno
underlineboolno
font_weightutf8no
accentutf8no
font_sizeutf8no
line_heightutf8no
font_familyutf8no
text_alignutf8no
text_transformutf8no
letter_spacingutf8no
paddingutf8no
marginutf8no
borderutf8no
fillutf8no
strokeutf8no
stroke_widthutf8no
stroke_linejoinutf8no
stroke_linecaputf8no
opacityutf8no

The light sub-block of a class: field overrides applied under a prefers-light colour scheme.

PropertyTypeRequiredDescription
colorutf8no
backgroundutf8no
boldboolno
italicboolno
underlineboolno
font_weightutf8no
accentutf8no
font_sizeutf8no
line_heightutf8no
font_familyutf8no
text_alignutf8no
text_transformutf8no
letter_spacingutf8no
paddingutf8no
marginutf8no
borderutf8no
fillutf8no
strokeutf8no
stroke_widthutf8no
stroke_linejoinutf8no
stroke_linecaputf8no
opacityutf8no

A stylesheet block: raw CSS injected verbatim into the rendered site, for styling beyond the class field set.

PropertyTypeRequiredDescription
nameidentifieryes
cssutf8yes
siteslist<symbol>no

A theme block: a named palette plus the dark / light palette sub-blocks that map colours onto every built-in element.

PropertyTypeRequiredDescription
nameidentifieryes
font_headutf8no
font_bodyutf8no
font_monoutf8no

Child blocks

SlotAcceptsMultipleDescription
palettespaletteyes

A palette sub-block of a theme: the colour roles (bg, fg, the named hues, …) for one colour scheme.

PropertyTypeRequiredDescription
modeidentifieryes
bgutf8no
book_bgutf8no
bg_altutf8no
bg_insetutf8no
overlayutf8no
borderutf8no
border_strongutf8no
fgutf8no
fg_mutedutf8no
fg_subtleutf8no
headingutf8no
selectionutf8no
accentutf8no
accent_2utf8no
linkutf8no
on_accentutf8no
syn_kwutf8no
syn_strutf8no
syn_numutf8no
syn_fnutf8no
syn_typeutf8no
syn_commentutf8no
syn_punctutf8no
redutf8no
orangeutf8no
yellowutf8no
greenutf8no
cyanutf8no
blueutf8no
purpleutf8no
pinkutf8no

An inline_pattern block: a custom inline text pattern recognised in prose, mapping a delimiter to a class or rendering.

PropertyTypeRequiredDescription
nameidentifieryes
patternutf8yes