Search code examples
vue.jsnuxt.jsvuetify.jsdarkmode

Vuetify DarkMode colors wrong after page reload


My Vuetify App now can correctly toggle to darkmode (hooray!) however, when a full page refresh occurs, the style colors do not change (my primary color is kept from the light mode)

I can toggle to light, then back to dark, and the colors shift correctly to the dark theme's colors.

net-net what is going on? from what i am reading, all i need to do is set this.$vuetify.theme.dark = true in the app mounted method, but it doesn't work...

UPDATE we are using a nuxt layout, and setting the dark = true on the vuetify theme:

  mounted() {
    console.log('darkMode:', this.darkMode);
    this.$vuetify.theme.dark = this.darkMode;
  },

Solution

  • Did some digging, found that this is a known issue with the darkmode vuetify meta data: https://github.com/vuetifyjs/vuetify/issues/13378

    Update: the git hub issue was closed, but the expected workaround did not work for me.

    I ended up throwing a half millisecond setTimeout to reset the this.$vuetify.theme.dark = true due to the meta code changing it again to false midway through the darkmode being applied.