A dark mode UI for Antora documentation sites.
|
Important
|
Use the GitHub release ui-bundle.zip (Default UI + this theme, pre-merged)—the habit every site should adopt.
The npm package is deprecated and unpublished; see npm deprecation (archive & lessons learned).
Discover this theme via Antora Supplemental docs (extensions registry).
|
Changelog: CHANGELOG.adoc (summaries) and changelog-details/ (dated detail files).
-
Dark mode toggle - A sun/moon icon button in the navbar that switches between light and dark themes
-
System preference detection - Automatically applies dark mode if the user’s OS is set to dark mode
-
Persistent preference - Remembers the user’s choice via
localStorage -
No FOUC (Flash of Unstyled Content) - Dark mode is applied before page render via inline script
-
Non-invasive - Works as a supplemental UI overlay; no need to fork or rebuild the Antora default UI bundle
-
Comprehensive styling - Covers navbar, navigation panels, content area, code blocks, tables, admonition blocks, footer, and more
-
Version pinning strategies — exact semver pin (recommended for production),
releases/latest, rolling line aliases (v1.0,v1.1,v1),supported-lines.json, and Renovate regex example; see the Version Pinning guide in the docs module.
We’ve submitted this theme for inclusion in the official Antora Default UI. If you’d like to see native dark mode support in Antora, please upvote the feature request:
Your support helps the Antora team prioritize this feature!
Doc-site chrome (mast, header layout, VCS icons) lives in the separate valentus-theme project. Pair valentus supplemental UI on top of this dark-mode release bundle when you want both.
Use the release bundle. That is the correct default—not a mild preference.
Point your playbook at a pinned GitHub Release asset. You do not need this project on npm.
ui:
bundle:
url: https://github.com/antora-supplemental/antora-dark-mode/releases/download/v1.2.0/ui-bundle.zip
snapshot: true
supplemental_files: ./supplemental-ui-overridesOptional supplemental_files is one directory of your files (logo, favicon)—not a second theme install.
Catalog and org docs: antora-supplemental.github.io/docs.
Former npm consumers: npm deprecation.
|
Warning
|
Antora accepts one supplemental directory or virtual files—not multiple directories in YAML. |
GitHub Releases have no npm-style ranges in the URL.
This theme documents three consumer strategies (float latest, exact pin, Renovate/~1.0.0) and publishes rolling prerelease aliases for line pins:
| Playbook URL | Meaning |
|---|---|
|
Exact pin (recommended for CI) |
|
Latest v1.0.x patch (moving tag) |
|
Latest v1.x.x (moving tag) |
|
Newest semver release (includes major bumps) |
Antora’s ui.supplemental_files accepts either a single filesystem directory or an array of virtual files (path + contents).
A YAML list of multiple directories is not supported—the array form is only for virtual entries.
Small override directory on the release bundle (typical: logo, favicon):
ui:
bundle:
url: https://github.com/antora-supplemental/antora-dark-mode/releases/download/v1.2.0/ui-bundle.zip
snapshot: true
supplemental_files: ./supplemental-ui-overridesMerged directory (vendored fork): Copy supplemental-ui into your repo, merge your changes, then point the playbook at that one folder:
ui:
bundle:
url: https://gitlab.com/antora/antora-ui-default/-/jobs/artifacts/HEAD/raw/build/ui-bundle.zip?job=bundle-stable
snapshot: true
supplemental_files: ./supplemental-uiVirtual files: add single assets without a full supplemental tree:
supplemental_files:
- path: img/logo.svg
contents: ./branding/logo.svgVirtual override of a single UI file: Each entry must use path and contents (inline or path to a file on disk).
If you replace a partial such as partials/head-meta.hbs, your file must still load this theme’s CSS and scripts (start from the theme’s partial), or use a merged directory instead.
If you want to vendor or heavily customize the dark mode assets, copy the supplemental-ui folder into your project from this repository.
-
Copy the folder:
cp -r supplemental-ui /path/to/your/antora-project/
-
Point the playbook at your copy, on top of the default UI bundle:
ui: bundle: url: https://gitlab.com/antora/antora-ui-default/-/jobs/artifacts/HEAD/raw/build/ui-bundle.zip?job=bundle-stable snapshot: true supplemental_files: ./supplemental-ui
See the dark theme in action: Live Demo
antora-dark-mode/
├── supplemental-ui/
│ ├── css/
│ │ └── site-extra.css # Dark mode CSS styles
│ ├── js/
│ │ └── site-dark-mode.js # Toggle button logic and theme management
│ └── partials/
│ ├── footer-scripts.hbs # Loads the dark mode script
│ └── head-meta.hbs # Loads CSS and prevents FOUC
├── docs/ # Demo documentation
│ ├── antora.yml # Component descriptor
│ └── modules/ROOT/
│ ├── nav.adoc # Navigation
│ └── pages/ # Sample pages
├── examples/
│ ├── antora-playbook.yml # Example playbook (release bundle; recommended)
│ └── antora-playbook-local.yml # Example playbook (bundle + optional overrides)
├── .github/workflows/
│ └── deploy.yml # GitHub Pages deployment
├── antora-playbook.yml # Playbook for demo site (online / CI)
├── antora-playbook-local.yml # Local playbook (cached assets, no fetch)
├── package.json
├── LICENSE
└── README.adocThis theme uses Antora’s supplemental UI feature to overlay additional files onto the default UI bundle. The approach involves four key files:
This Handlebars partial is injected into the <head> of every page.
It does two things:
-
Loads the
site-extra.cssstylesheet -
Runs a tiny inline script that immediately applies the
dark-themeclass if the user previously selected dark mode or if their OS prefers dark mode
This prevents the brief flash of light mode before the main JavaScript loads.
This partial is injected at the end of the page body. It loads the main site script, highlight.js, and the dark mode toggle script.
This JavaScript module:
-
Injects a toggle button into the navbar (
.navbar-end) -
Handles click events to switch between light and dark themes
-
Persists the user’s preference in
localStorageunder the keyantora-theme -
Updates the button icon (sun for dark mode, moon for light mode)
-
Respects the user’s OS preference if no saved preference exists
Edit supplemental-ui/css/site-extra.css to customize the color palette.
The current theme uses these primary colors:
| Variable | Value | Usage |
|---|---|---|
Background (main) |
|
Page body background |
Background (elevated) |
|
Sidebar, navigation panels, blocks |
Background (navbar) |
|
Top navigation bar |
Text (primary) |
|
Main body text |
Text (headings) |
|
Headings and titles |
Link color |
|
Hyperlinks |
Link hover |
|
Hovered hyperlinks |
Border color |
|
Dividers and borders |
To style additional elements not covered by the default theme, add new selectors prefixed with html.dark-theme:
html.dark-theme .my-custom-element {
background-color: #25262b;
color: #c1c2c5;
}By default, the toggle button is inserted at the beginning of .navbar-end.
To change its position, modify the ensureToggleButton() function in site-dark-mode.js:
// Insert at the end instead of the beginning
navbarEnd.appendChild(button);This theme supports all modern browsers:
-
Chrome/Edge (latest)
-
Firefox (latest)
-
Safari (latest)
-
Opera (latest)
The theme uses standard CSS and JavaScript that works in all browsers supporting:
-
localStorage -
classList -
matchMedia
| Component | Version |
|---|---|
Antora |
3.x |
Antora Default UI |
Any version (HEAD recommended) |
Node.js |
18+ |
Make sure localStorage is available and not blocked by browser settings or extensions.
Check the browser console for errors.
The toggle button is injected into .navbar-end.
If your UI bundle has a different structure, you may need to modify the selector in site-dark-mode.js.
Ensure head-meta.hbs is being loaded correctly.
Check that the inline script isn’t being blocked by a Content Security Policy.
Contributions are welcome! Please feel free to submit issues and pull requests.
-
Fork the repository
-
Create a feature branch:
git checkout -b feature/my-feature -
Commit your changes:
git commit -m "Add my feature" -
Push to the branch:
git push origin feature/my-feature -
Open a pull request
This project is licensed under the MIT License. See the LICENSE file for details.
-
The Antora team for creating an excellent documentation site generator
-
The Antora Default UI which this theme extends
-
Fossil SCM — acknowledged as a solid alternative to Git for version control; see the docs for a short discourse and plans for Dev-Centr support