5

I want to use the variables defined in my vuetify theme in the style portion of my vue files. Its not mentioned on the docs and can't seem to find an answer anywahere, does anyone know how to do this?

e.g.

Vue.use(Vuetify, {
  theme: {
    primary: '#3f51b5',
  }
})

now in my Home component I want to do:

<template>
    <h1>My Title</h1>
</template>

<styles>
    h1{
        color:$primary; #from the vuetify theme
    }  
</styles>
6
  • Possible duplicate of Using custom theming in Vuetify and pass color variables to components
    – Traxo
    Commented Oct 10, 2018 at 10:48
  • The answers on the other question are more work arounds than official solutions, which is ideally what i want. Though if there isn't one then I guess the work around will have to do.
    – Brad
    Commented Oct 10, 2018 at 13:10
  • > The answers on the other question are more work arounds than official solutions, One of the answers quotes official statement about this issue. And reply on that answer is by one of the Vuetify devs. So it doesn't negate the fact that this is a duplicate question (at least I don't see any difference?). I.e. afaics the official "solution" is a "workaround", lol.
    – Traxo
    Commented Oct 10, 2018 at 13:11
  • The official answer was referring to stylus, not scss - though don't know if the same applies
    – Brad
    Commented Oct 10, 2018 at 13:17
  • 2
    I have updated answer, found docs with that regard, check it out!
    – Traxo
    Commented Oct 16, 2018 at 18:26

2 Answers 2

3

U can use:

<style scoped>
  .something {
    color:            var(--v-primary-base);
    background-color: var(--v-accent-lighten2);
  }
</style>

From this list:

  --v-anchor-base: #c42742;
  --v-primary-base: #c42742;
  --v-primary-lighten5: #2c0447;
  --v-primary-lighten4: #cfa854;
  --v-primary-lighten3: #dd88cc;
  --v-primary-lighten2: #b49921;
  --v-primary-lighten1: #f899c7;
  --v-primary-darken1: #0169dc;
  --v-primary-darken2: #c28fd0;
  --v-primary-darken3: #fbe002;
  --v-primary-darken4: #33303a;
1
0

Update for Vuetify 3 (on top this answer above):

The Upgrade Guide makes brief mention of changes, but doesn't go into detail. Instead of:

<style scoped>
  .something {
    color:            var(--v-primary-base);
    background-color: var(--v-accent-lighten2);
  }
</style>

You'll now do this:

<style scoped>
  .something {
    color:            rgb(var(--v-theme-primary));
    background-color: rgba(var(--v-theme-primary), 0.3);
  }
</style>

As of this writing, the available options are listed in the vuetify theme spec test file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.