Theme Packs
Installable design bundles layered on top of the color-scheme system — bundled packs, the switcher UI, and the zudo-doc theme CLI.
A theme pack is an installable design bundle — a stylesheet, a metadata file, and optional self-hosted fonts — that restyles the whole site in one move: design tokens, font stacks, and component details. Packs ship inside @takazudo/zudo-doc, are selected with a single config field, and can be switched live from an optional on-page switcher.
Theme packs vs color schemes
zudo-doc has two theming layers, and they are independent by contract:
Color schemes are the ramp-native light/dark palettes — the
colorScheme/colorModeconfig fields, the header appearance menu (Light / Dark / System), andlight-dark()resolution. They decide what "light" and "dark" mean on your site. See Color.Theme packs are installable design bundles layered on top. A pack overrides design tokens, swaps font stacks, and may restyle components — and it defines both its light and dark values via
light-dark(), so every appearance choice continues to work on every pack.
Switching packs never touches the selected appearance preference, and choosing an appearance never touches the active pack. System follows the device independently of the selected pack.
| Color schemes (mode system) | Theme packs | |
|---|---|---|
| Config fields | colorScheme, colorMode | themePack, themePackSwitcher, themePacks |
| DOM attribute | <html data-theme> | <html data-theme-pack> |
| Persistence key | localStorage["zudo-doc-theme"] | localStorage["zudo-doc-theme-pack"] |
| Change event | color-scheme-changed | theme-pack-changed |
Note
The bare word "theme" always refers to the light/dark mode system. Everything in the pack layer says theme pack — data-theme and color-scheme-changed are not part of the theme-pack API, and packs never read or write them.
Bundled packs
Thirty-four packs ship with @takazudo/zudo-doc — the full catalog, with each pack's badge, fonts, and apply snippet, lives in the Theme Gallery. A few packs have special roles in the collection:
| Slug | Description |
|---|---|
graphite | The default look. A soft, low-glare neutral pack with one warm copper accent. A project that does not set themePack gets Graphite, and the slug default is an alias for it. |
warm-mineral, quiet-slate | The other two soft-tone packs. They share Graphite's component treatment and differ only in palette: sandstone and umber with a terracotta accent, and misty blue-grey slate with a muted copper accent. |
classic (shown as Classic) | The original zudo-doc look. A reserved pack that ships only metadata — no pack stylesheet is ever loaded for it, so it costs zero extra requests. Before 10.0.0 its slug was default. |
foundry | The reference pack: a GitHub-neutral baseline — white paper, near-black ink, Primer-blue links — that restyles every token surface, including all 9 --zd-syntax-* code-highlighting roles, in both light and dark. |
The soft-tone packs
Graphite, Warm Mineral and Quiet Slate keep text calm without washing it out. All three use the same rules:
Headings get a slightly stronger ink than body text, and the header, footer and table headers sit on a soft surface tone.
Decorative rules (dividers, table lines, sidebar edges) use a quiet
linecolor. Controls you interact with (buttons, inputs, dropdowns, the search dialog) use a stronger control border with at least 3:1 contrast.The current page in the sidebar and header, and the active table-of-contents entry, use a soft active fill, the accent ink and a 3px accent marker.
Tags, admonitions, code-line highlights and diff insert/delete rows use opaque soft fills. Every syntax color stays at 4.6:1 or better on each of them.
Keyboard focus is a 2px accent outline with a 3px offset. Inside the sidebar and table-of-contents scrollers the outline sits inside the element so it is never clipped.
The Classic pack keeps its historical palette, where muted text and borders share one color. The soft-tone packs separate those two roles, so muted text can stay readable while dividers stay quiet.
Choosing a pack
Three config fields control the feature:
| Field | Default | What it does |
|---|---|---|
themePack | omitted (Graphite) | The active pack slug. Omitted means "graphite", except in the two cases described below. |
themePackSwitcher | false | Mounts the bottom-right switcher flyout (and its browse-all dialog) on every page. |
themePacks | undefined | The enabled pack slugs, in switcher order. undefined enables all bundled packs — "graphite" first, then "classic", then the rest alphabetical. |
export default defineConfig(
zudoDoc({
siteName: "My Docs",
themePack: "foundry",
themePackSwitcher: true,
themePacks: ["classic", "foundry"],
}),
);An explicit
themePackslist is authoritative: it may omit"classic", and its order is the switcher's Prev/Next cycle and the browse-all grid order. Graphite is never inserted into it for you.An unknown or duplicate slug — in
themePackorthemePacks— fails the build loudly at plugin setup, naming the bad slug and the available ones. There is no silent fallback at build time.themePackcan name a non-default pack whilethemePackSwitcherstaysfalse: a build-pinned look with no switching UI.
When the default is Classic instead
An omitted themePack resolves to Graphite, with two exceptions where your own palette should keep control:
You pass custom
colorSchemes. A project that authors its own palettes keeps the no-stylesheet Classic look, so Graphite never paints over them.You set
colorMode: false(a single fixed scheme).
An explicit themePack always wins over both rules. Set themePack: "classic" to keep the Classic look in any project.
Upgrading an existing project
No
themePackset: the site uses Graphite. To keep the Classic look, addthemePack: "classic".themePack: "default"set: from 10.0.0,defaultis an alias for Graphite, so the site switches to Graphite. Change it tothemePack: "classic"to keep the Classic look."default"in an explicitthemePackslist: it now enables Graphite. Write"classic"to keep Classic in the list. Listing both"default"and"graphite"fails the build as a duplicate.An explicit
themePackslist without"graphite": the build fails with an error that names the fix. Either add"graphite"tothemePacks, or setthemePackto one of the listed packs (themePack: "classic"keeps the Classic look).Saved reader selections: a reader who picked Classic in the switcher before 10.0.0 has
defaultstored inlocalStorage["zudo-doc-theme-pack"]. That slug no longer names a pack, so the page falls back to the configured pack until the reader picks again. Every other stored slug stays valid.
Packs with a fixed color mode
With colorMode: false and an explicit pack, the pack follows the CSS color-scheme of the page, and packs never set color-scheme themselves. To show a pack's dark values on a fixed-dark site, declare it in your host CSS:
html {
color-scheme: dark;
}The switcher UI
With themePackSwitcher: true, a small round launcher button sits fixed at the viewport's bottom-right. Clicking it opens a flyout card showing the active pack's name, its Light/Dark badge (the pack's designed-primary mode), and its description, along with:
Prev / Next — cycle through the enabled packs, with wraparound, in
themePacksorder.Browse all (grid icon) — opens the full-grid dialog described below.
✕ / Esc — close the card.
The card only advances when a switch actually commits — if a pack's stylesheet fails to load, the current pack stays applied and the UI does not move.
The browse-all dialog
The grid dialog shows one card per enabled pack — a mini preview (heading sample, prose line, and a code line in the pack's syntax colors), the pack name, its Light/Dark badge, and its description. Two behaviors are deliberate:
Browsing downloads no packs. Cards are painted from resolved preview swatches in each pack's metadata, matching the current light/dark mode — browsing the whole catalog fetches zero pack stylesheets and zero webfonts.
Applying keeps the dialog open. Clicking a card applies that pack to the live page immediately; the dialog stays open so you can compare looks side by side. Close it with Esc, the ✕ button, or the backdrop. The active card carries a selected ring that follows switches made from any surface.
Persistence and runtime behavior
The reader's choice persists in
localStorage["zudo-doc-theme-pack"]and is re-applied by a pre-paint bootstrap — hard loads render with the right pack from the first frame (no flash of the default look), and the choice survives SPA navigation. Visitors without JavaScript get the configuredthemePack.A stored slug that is no longer enabled (removed pack, typo, tampering) silently falls back to the configured
themePack.Only the active pack's CSS and fonts are ever downloaded — switching fetches the incoming pack's stylesheet, waits for it to load, then flips atomically. The
classicpack loads nothing.For tests and integrations: the active slug is always readable from
<html data-theme-pack="…">, and every committed switch dispatches atheme-pack-changedevent onwindowwithdetail: { pack, previous }.
The theme CLI
The zudo-doc bin (from @takazudo/zudo-doc) has a theme subcommand. It is fully offline — the catalog comes from the installed package and the active pack from your zfb.config.ts; nothing is fetched from the network.
# list the installed packs and which one is active
pnpm exec zudo-doc theme list
# switch the project to the foundry pack
pnpm exec zudo-doc theme apply foundrytheme list prints each installed pack's slug, name, mode, version, and description, and marks the one your project currently has configured.
theme apply <slug>:
resolves the
defaultalias tographite, then validates the slug against the installed catalog — an unknown slug is rejected along with the list of available ones;rewrites the
themePackfield inside thezudoDoc({ … })call inzfb.config.ts, adding the field if it is missing;refuses cleanly when the config is not in the canonical scaffold shape (for example, settings hidden behind a spread) — it explains why, prints the one-line edit to make by hand, and never writes a partial change;
is idempotent — re-applying the already-configured slug leaves the file untouched;
records provenance (slug, pack version, timestamp) in
.zudo-doc.json, the same lazily-created filezudo-doc ejectuses.
Scaffolding with a pack
create-zudo-doc can start a project on any bundled pack — via the --theme-pack <slug> flag or the interactive "Theme pack:" prompt (asked between the color-scheme questions and the feature multiselect). The switcher UI is a separate feature toggle. See the create-zudo-doc CLI reference.
pnpm create zudo-doc my-docs --theme-pack foundry --theme-pack-switcherLight/dark and the Design Token Panel
A pack's Light/Dark badge is its designed-primary mode — a hint about which mode the pack was designed around, not a capability flag. Every pack defines both modes, and the header appearance menu works identically on all of them.
Design Token Panel tweaks are per-pack: an override you save while pack A is active is stored against pack A, hidden while another pack is active, and restored verbatim when you switch back. On the Classic (
classic) pack the panel keeps using its originalzudo-doc-tweakstorage, so tweaks saved before theme packs existed survive an upgrade untouched. Graphite tweaks are stored underzudo-doc-tweak--graphite.
Emitting the pack stylesheet yourself
Most projects never need this. It applies only to a host or embedder that emits the pack stylesheet <link> itself — typically so the link survives zfb's head swap. The pre-paint bootstrap will use your link instead of inserting its own, but only under a strict ordering contract.
Emit it before the zudo-doc head bootstrap, and tag it
data-zd-theme-pack-css. The bootstrap looks for a link carrying that attribute whosehrefmatches the resolved pack; finding yours, it inserts nothing — one element, one request.Match the href exactly, including the cache-busting query:
{base}theme-, wherepacks/ <slug>/ pack. css? v= <pack version> {base}is the site's base path with its trailing slash and the version is the one in the pack'smeta.json. The check is an exact string comparison, so a link missing the?v=part reads as a different stylesheet and you get both.data-zfb-transition-persistalone is not enough. The check keys ondata-zd-theme-pack-css; a link tagged only for zfb's transition persistence is invisible to it.Emitted after the bootstrap, a cold boot ends up with two
<link>elements on one href. The bootstrap runs first and cannot see a link the parser has not reached yet, and nothing later can undo it on that first paint: by the time any post-parse handler could merge the two elements, the parser has already committed to both. Whether that costs a second network request depends on how the stylesheet is served: normally the duplicate href is a cache hit, so the cost is just the redundant element — but underCache-Control: no-storeit is a genuine second fetch, which is how the original report measured it (same URL, same wire bytes, twice per cold boot).
<!-- must precede the zudo-doc head bootstrap; slug and ?v= are YOUR pack's, read from its meta.json -->
<link rel="stylesheet" data-zd-theme-pack-css href="/theme-packs/my-pack/pack.css?v=1.0.0" />Authoring a pack
A pack is one directory — theme-packs/<slug>/ — holding pack.css, meta.json, and an optional fonts/ folder. meta.json carries the pack's identity (slug, display name, description, Light/Dark badge, version) plus the resolved preview swatches the browse-all dialog paints its cards from.
html[data-theme-pack="my-pack"] {
--zd-bg: light-dark(#ffffff, #0d1117);
--zd-accent: light-dark(#0969da, #4493f8);
--zd-syntax-keyword: light-dark(#cf222e, #ff7b72);
--font-sans: "Jost", system-ui, sans-serif;
--zdc-doc-title-weight: 600;
}The short version of the authoring contract:
Scope every rule under
html[data-theme-pack="<slug>"]. This is what makes switching atomic and guarantees an inactive pack can never leak styles.Define both modes for every color via
light-dark(lightValue, darkValue). Packs never declarecolor-scheme:and never select on[data-theme]— mode stays the toggle's job.Override the
--zd-*semantic roles (including the 9--zd-syntax-*highlighting roles) and--zdc-*component seams — never the--color-*utility aliases, which would break the Design Token Panel's live-edit round-trip.Restyle extras only against stable DOM hooks (
header[data-header],#desktop-sidebar,[data-admonition],pre.hi-root,a[data-zd-tag-chip]with its[data-zd-tag-chip-outline],[data-zd-tag-chip-label]and[data-zd-tag-count]parts, …) — never against zudo-wind utility class names.Keep the
[data-header-logo]anchor a block-level box (display: block/inline/inline-block/flow-root, and nooverflow/white-space/text-overflowoverride) — the header component's owntruncateclass needs it for the ellipsis on a long site name. Put a logo marker (square, dot, …) on::before/::afterinstead of turning the anchor itself into a flex or grid container.
The --font-sans override reaches prose and the whole chrome through body { font-family: var(--zdc-chrome-font, var(--font-sans)) }. Optional --zdc-header-font, --zdc-sidebar-font, and --zdc-toc-font seams let a pack choose a different family for one surface. The component selectors cover desktop and mobile chrome. Check their computed values on built pages, including repeated client navigation; retained islands preserve unchanged effective identity and props, while changed identity or props recreate their render scope.
Fonts are self-hosted OFL Google Fonts or system stacks — nothing else, declared with
font-display: swapand a fallback stack that ends in a generic family. Commercial faces are never load-bearing and never referenced (nolocal("Futura")entries) — a Futura-flavored pack loads Jost, its OFL stand-in. This is what makes every pack render identically offline and under a strict CSP.
A build-time validator enforces the whole contract — scoping, the token-name manifest, font parity, the commercial-face denylist — so a broken pack fails the package build, never your site build. The full architecture (metadata schema, swap algorithm, validator rules) is locked in the theme-packs ADR.
See also
Theme Gallery — the full catalog of bundled packs
Color — the color-scheme layer packs build on
Design Token Panel — live token tweaking; tweaks are saved per pack
Customizing zudo-doc — where theme packs sit on the escalation ladder
create-zudo-doc CLI — scaffolding with
--theme-packConfiguration — the full
zudoDoc()field reference