Skip to content

Is there a way to detect dark/light mode switch? #415

Answered by meteorlxy
Jasenkoo asked this question in Q&A
Discussion options

You must be logged in to vote
import { useDarkMode } from '@vuepress/theme-default/lib/client'
import { watch } from 'vue'

export default {
  setup() {
    const isDarkMode = useDarkMode()
    watch(isDarkMode, () => {
      // ...
    })
  },
}

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@Jasenkoo
Comment options

@ottopaulsen
Comment options

@Jasenkoo
Comment options

Answer selected by meteorlxy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants