Dark mode
Less than 1 minute
The theme supports dark mode and allows you to customize it.
Options
You can config dark mode through darkmode in theme options.
import { hopeTheme } from "vuepress-theme-hope";
export default hopeTheme({
darkmode: "switch", // or "toggle", "auto", "enable", "disable"
// other options...
});Available options:
"switch": switch between dark, light and auto (default)"toggle": toggle between light mode and dark mode"auto": Automatically decide whether to apply dark mode based on user device's color-scheme or current time"enable": only dark mode"disable": disable dark mode
Try it
Toggle the button to see effects:
Getting Status
In Markdown files or Vue Template, you can access
$isDarkModeto get dark mode status directly:Darkmode enabled: {{ $isDarkMode }} <img v-if="$isDarkMode" src="/dark.png" alt="dark" /> <img v-else src="/light.png" alt="light" />In scripts, you can import
useDarkModefromvuepress-theme-hope/clientto get dark mode status:import {useDarkMode} from "vuepress-theme-hope/client"; export default {setup() { const {isDarkMode} =useDarkMode();console.log(isDarkMode.value); // get dark mode status }, };
Changelog
5/8/25, 9:52 AM
View All Changelog
0fa9a-on1e9f5-on55e92-onb1230-ona0268-onba382-on93385-on2c32a-on6d493-one788a-onb41c0-ond72d7-on54c46-on1ba82-on2a306-on8174c-onf5b66-on79ac6-on2243a-on98f84-on2c32c-on3dac6-on2fa50-on55cc9-on9856d-onc540c-onf18b7-onfd395-on1eb77-onbcf02-on60053-on0c093-on62d19-onf6ff0-on3c199-on