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
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With