Loading
feat: add dark mode support with toggle button
Summary
This MR adds dark mode support to the Antora Default UI with a toggle button in the navbar.
Features
- Toggle button - Sun/moon icon in the navbar that switches between light and dark themes
- System preference detection - Automatically applies dark mode if the user's OS prefers dark mode
- Persistent preference - Remembers the user's choice via localStorage
- No FOUC - Dark mode is applied before page render via inline script in head-meta.hbs
What's included
src/css/dark-mode.css- All dark mode styles usinghtml.dark-themeselector prefixsrc/js/07-dark-mode.js- Toggle button logic and theme managementsrc/partials/head-meta.hbs- FOUC prevention scriptsrc/css/site.css- Import for dark-mode.css
Styling coverage
- Navbar, navigation panels, sidebar, footer
- Code blocks with syntax highlighting optimized for dark mode
- Admonition blocks with subtle accent colors per type (note, tip, warning, caution, important)
- Tables, quotes, examples, sidebars, and all block types
- Component/version selector dropdown
- Keyboard, button, and menu macros
- Tabs extension support
Reference implementation
This is based on a working supplemental UI that's been tested in production:
- GitHub: https://github.com/the-dev-center/antora-dark-theme
- Live Demo: https://the-dev-center.github.io/antora-dark-theme
Closes #216