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...
});darkmode
'switch' | 'toggle' | 'auto' | 'enable' | 'disable'Default
'switch'Whether to enable dark mode support:
'switch': switch between dark, light and auto'toggle': toggle between light mode and dark mode'auto': automatically decide whether to apply dark mode based on the user device 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
9/28/26, 12:45 PM
View All Changelog
0c1aa-on0fa9a-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