Theme overrides
This module exposes its colours as CSS custom properties (variables) using the --dx-* prefix. Most shortcodes share a common palette (surface + status tones), so you can theme all dx/* components consistently without forking or copying the moduleâs CSS.
The rule: define your overrides after the dx stylesheet
| |
If your theme doesnât use extend-head.html, the same rule still applies: include your override CSS after the dx stylesheet.
This applies to both colour palette tokens and dx/code syntax token overrides.
Customizing syntax highlighting
dx/code uses Hugoâs built-in syntax highlighter (Chroma). The dx stylesheet maps common Chroma token classes to CSS variables so you can theme code blocks without editing module CSS.
1) Make sure Hugo uses classes (not inline styles)
In your site config, set:
| |
If noClasses is true, Hugo will emit inline styles and CSS-variable overrides wonât apply cleanly.
2) Override dx/code token colours
Add overrides after the dx bundle (same rule as colours). For example:
| |
3) Dark-mode token overrides
Scope overrides to your themeâs dark-mode selector (dx listens for several common ones):
| |
Tip: if a theme uses a different dark-mode signal, target whatever changes on the <html> element when you toggle the theme.
Theme compatibility
Different Hugo themes signal dark mode in different ways. The dx stylesheet listens for several common patterns so it âjust worksâ across most themes.
Here are the most common ones youâll run into:
- Blowfish / Tailwind-style themes: add a
.darkclass to the<html>element (e.g.html.dark). - Data-attribute themes: set
data-theme="dark"ordata-scheme="dark"on<html>. - Bootstrap-style themes: set
data-bs-theme="dark"on<html>.
If your theme uses a different mechanism, you can still override dx tokens by targeting whatever selector your theme applies in dark mode (the important part is that your overrides run after the dx stylesheet).
Tip: use your browser devtools to inspect the <html> element while toggling the theme â whatever class/attribute changes there is the best selector to use.
Global overrides
To change colours across the entire site, define overrides on :root in a stylesheet that loads after the dx stylesheet:
| |
Scoped overrides (only part of the site)
CSS variables cascade, so you can scope overrides to a specific container:
| |
Then wrap the relevant content:
| |
Only bgboxes inside that container will use the overridden values.
Dark mode overrides
The module normalizes dark mode across themes by looking for common dark-mode signals (for example html.dark in Blowfish, or [data-theme="dark"] in other setups). To override only in dark mode, target one of those signals:
| |
Where to find the variables
Default values live in the moduleâs token layer (SCSS), primarily assets/dx/scss/_tokens.scss. Component-specific rules live alongside it (for example _bgbox.scss). In most cases youâll get the best results by overriding the shared palette tokens (--dx-surface, --dx-info-bg, etc.) rather than per-component internals.