Skip to main content

Customising dark theme

Light and dark colour modes come from the classic Docusaurus theme. With this template, you can change how the initial theme is chosen.

Template configuration

In docusaurus.config.js, under themeConfig, the only colorMode setting is:

docusaurus.config.js
colorMode: {
respectPrefersColorScheme: true,
},

Everything else uses Docusaurus defaults:

OptionTemplate valueMeaning
respectPrefersColorSchemetrueOn a first visit, follow the OS light/dark preference
defaultMode'light'Used only when system preference is not applied (for example if you set respectPrefersColorScheme: false)
disableSwitchfalseTheme toggle stays visible in the navbar

Disabling dark theme

To keep the site in light mode only (no toggle, ignore OS dark preference), set all three options:

docusaurus.config.js
colorMode: {
defaultMode: 'light',
disableSwitch: true,
respectPrefersColorScheme: false,
},
OptionEffect
defaultMode: 'light'Use light mode
disableSwitch: trueHide the navbar theme toggle
respectPrefersColorScheme: falseDo not follow the OS colour scheme
note

Turning off dark theme does not remove the need to check contrast for light mode. If you later re-enable dark mode, review graphics again.

Graphics in light and dark mode

When dark theme stays available, some images (dark logos, black icons, light-on-white diagrams) can disappear or look wrong on a dark background.

For theme-aware assets, like two files with ThemedImage, or one SVG using currentColor, see Using images in light and dark mode.