Dynamically change Vuetify 3 themes - step-by-step guide
P粉811329034
P粉811329034 2023-12-05 16:03:16
0
1
591

I want to change the theme dynamically. I defined lightTheme and darkTheme li

export default createVuetify({
  theme: {
    defaultTheme: "lightTheme",
    themes: {
      lightTheme: {
        dark: false,
        colors: {
          primary: "#ad1c3d",
          "page-header-background": "#d7d7ce",
          "page-background": "#cdcdc1",
          "table-header": "#cdcdc1",
          background: "#c0c0b5",
          "header-background": "#b5b5a6",
          "info-text": "#666660",
        },
      },
      darkTheme: {
        dark: true,
        colors: {
          primary: "#52E3C2",
          "page-header-background": "#282831",
          "page-background": "#32323E",
          "table-header": "#2e2e2e",
          background: "#3F3F4A",
          "header-background": "#4a4a59",
          "info-text": "#99999F",
        },
      },
    },
  },
});

I can access the theme using this.$vuetify.theme, but I can't find how to change the theme at runtime. The way to do this is different in Vuetify 2. I can't find any examples of Vuetify 3.

What is the correct way to dynamically change themes in Vuetify 3?

P粉811329034
P粉811329034

reply all(1)
P粉736935587

The documentation seems incorrect. The documentation says to use

this.theme.global.name.value = "themeName"

but actually

this.theme.global.name = "themeName"
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template