10

I enabled custom properties:

Vue.use(Vuetify, {
    options: {
        customProperties: true
    }
});

and trying to use through CSS variable :

<style>
    .custom{
        color:var(--v-primary-base);
    }
</style>

this is vuetify.js file where I am setting theme :

export default new Vuetify({
    icons: {
        iconfont: 'mdi',
    },
    theme: {
        themes: {
            light: {
                background: '#FFFFFF',
                primary: '#25316A',
                secondary: '#b0bec5',
                accent: '#25316A',
                error: '#E86674',
                orange: '#FF7A0D',
                golden: '#A68C59',
                badge: '#F5528C',
                customPrimary: '#085294',
            },
            dark: {
                primary: '#085294',
            }
        },
    },
})

None of the theme colors are accessible through variables. I tried many ways but hasn't worked and no error thrown. Any one can please help me?

T. Short
  • 3,481
  • 14
  • 30
Himakar
  • 345
  • 4
  • 17

2 Answers2

18

You need to pass the options property to the Vuetify instance instead, not in the use function.

From the docs:

export default new Vuetify({
  theme: {
    options: {
      customProperties: true,
    },
    // ...
  },
})
hhs
  • 196
  • 2
  • 4
  • Vuetify's variables stop working at this point, why is that? you cant use variables.scss for example and define $stepper-header-height: or something .. (without customProperties, this works) – trainoasis Dec 18 '20 at 12:16
6

You have to use the options in vuetify file but you have used it in wrong place like this...

export default new Vuetify({
    icons: {
        iconfont: 'mdi',
    },
    theme: {
        options: {
            customProperties: true,
        },
        themes: {
            light: {
                background: '#FFFFFF',
                primary: '#25316A',
                secondary: '#b0bec5',
                accent: '#25316A',
                error: '#E86674',
                orange: '#FF7A0D',
                golden: '#A68C59',
                badge: '#F5528C',
                customPrimary: '#085294',
            },
            dark: {
                primary: '#085294',
            }
        },
    },
})

After that when you want to use your custom CSS variable as you made it you have to use it like this..

<style>
    .custom{
        color:var(--v-golden-base);
    }
</style>

Here base is a default and I showed for the golden variable but You can use any of them.

NorthWind
  • 3
  • 3
Mithun Das
  • 435
  • 4
  • 8