Theme Colors
Color system used in DocuBook for styling UI elements
DocuBook comes with a config-driven theme system that lets you switch between color presets or define custom colors — all from docu.json. Each preset includes both light and dark modes with full variable coverage.
Config-Driven Themes
Set your theme in docu.json using the themes.colors field. The system supports preset names and custom hex values.
Quick Start
Switch to another preset:
Use a custom brand color:
The system automatically generates all 24 CSS variables (background, foreground, primary, accent, daisyUI tokens, etc.) for both light and dark modes from a single primary color. No need to hand-craft every variable.
Note: Only
primaryis configurable when using custom hex. The entire 24-variable palette (light + dark) is auto-generated from it.
Available Presets
CLI Override
Override the theme without editing docu.json using the --theme flag:
This is useful for testing themes quickly across all commands (dev, build, preview).
How It Works
Themes are powered by @docubook/themes-colors, a separate package that ships:
- JSON data — preset theme variables and syntax tokens, CDN-ready via jsdelivr
- Resolver — maps
docu.jsonconfig to actual theme values (preset lookup or custom hex → HSL) - CSS generator — produces the complete
@layer baseblock with:rootand.darkvariable sets
Architecture
The theme CSS is compiled into the same bundle as Tailwind globals and injected as inline <style> for FOUC prevention.
Token Coverage
Each preset includes 24 CSS variables per mode (root + dark):
Plus 12 syntax tokens (keyword, function, punctuation, comment, string, constant, annotation, boolean, number, tag, attrName, attrValue) for code highlighting.
Last updated Jul 4, 2026