Skip to content

Support darkmode in other frameworks #4777

Answered by Mister-Hope
bongxin asked this question in Q&A
Discussion options

You must be logged in to vote

Similar things can be done with the following easily:

import { useDarkMode } from '@vuepress/helper/client' // install it first!

// in setup functions:
const darkMode = useDarkMode();

onMounted(() => {
  watch(darkMode, (value) => {
    if (value) document.docuementElement.classList.add('dark')
    else document.docuementElement.classList.remove('dark')
  }, { immediate: true })
})

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Mister-Hope
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
good first issue Good for newcomers wontfix This will not be worked on
2 participants
Converted from issue

This discussion was converted from issue #3355 on March 07, 2025 06:50.