Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to override vuetify styles?

I want to override the vuetify style by class.

For example to change the background color of button from vuetify.

So, I create a button with class on it:

<div id="app">
  <v-btn class="some" color="success">Success</v-btn>
</div>

.some {
background-color:red;
}

But the background-color red is override by vuetify.

How to solve this issue without using important and themes?

Here is example: https://stackblitz.com/edit/vue-js-gpkj6k

like image 856
Weved Avatar asked Sep 13 '18 08:09

Weved


People also ask

How to override style in Vuetify?

To override Vuetify styles with Vue. js, we can add scoped styles with the deep selector. to add the scoped attribute to styles to keep the styles applied to the current component only. And then we use >>> or ::v-deep to select the Vuetify class with the styles we want to override.

How do I override Vuetify sass?

You can override the Sass variables only there where you import the stylesheet using those. If you eg. import (directly or transitively) ~vuetify/src/components/VBtn/_variables. scss into your global stylesheet and then in your component (a separate stylesheet) you want to change $btn-text-transform , it won't work.

Can you use Vuetify without Vue?

No, you can't run Vuetify without Vue. The reason is pretty simple, most of Vuetify is built with vue and most of those components require their script to run, so everything that's not entirely css based will not work.


1 Answers

Having worked with Vuetify and it's various styling... eccentricities... I believe it's all boiled down to writing css that has more specificity than Vuetify.

It's never great practise to style element's directly (img), instead apply your own classes.

This way you could declare .my-card.v-card and win the specificity war, all the while keeping styles scoped (non scoped can the the devil to debug in vue files).

Some Vuetify style declarations use !important... so the only way I've found to override these are to also use !important on the override. IMO terrible decision from Vuetify to have any !important styles.

It's also good to get your head around >>>, /deep/, ::v-deep as can provide a solution where styles are not filtering through.

like image 96
4uroraskye Avatar answered Sep 20 '22 06:09

4uroraskye