Dark mode
A persistent, flash-free light and dark toggle.
Toggle light and dark from the nav. The choice is saved to localStorage and applied before
the page paints, so there is no flash of the wrong theme on load.
Syntax highlighting switches with the theme too. Code blocks use matching light and dark Shiki themes.
Which mode a reader starts in
A reader who has never touched the toggle gets whatever defaultLightingMode says:
export const config = defineThemeConfig({
defaultLightingMode: "auto", // "auto" | "light" | "dark"
});
auto follows the operating-system preference. light and dark pin the site to one of them
until the reader chooses otherwise. A stored choice always wins over the default.
Turning dark mode off
darkMode: false makes the site light-only:
export const config = defineThemeConfig({
darkMode: false,
});
The toggle disappears from the nav, the dark palette is never applied, and the operating-system
preference is ignored. It is a different setting from defaultLightingMode: "light", which starts
readers in light mode but keeps the toggle.
The two can contradict each other. darkMode: false with defaultLightingMode: "dark" asks for
a dark site with no way out of it, so the switch wins: the mode is pinned to light and the build
warns.