Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I change Vuetify's primary text color?

In a few places, vuetify sets text color to the "primary color" defined in its theme (eg. hilighting selected drop down menus). With my company's colors, this looks ugly. How can I set this to be different?

From what I can tell, this comes from these css rules:

.v-application.primary--text {
    color: #0064a2 !important;
    caret-color: #0064a2 !important;
}

When I change those, I can make the text color look nice. Unfortunately, they're generated by vuetify and marked as !important, so I can't seem to change them outside of the browser inspector.

I can add something like 'primary--text': 'color: #FF00FF' to the style theme, but that changes the background color, not the text color.

Here's a codepen example

I could use vuetify's themes exclusively for text, and set the rest of the element colors manually, but this doesn't seem to be their intended use. What should I do to change the text color?

like image 472
Christopher Waugh Avatar asked Jan 02 '20 21:01

Christopher Waugh


People also ask

Is it possible to change the default color of vuetify theme?

I am using Vuetify in my Nuxt app. I used the dark theme of that. according to Theme configuration of the official website we can change primary or secondary or other colors of the theme with our desired colors. But when we set for example dark theme the default text and background colors are set to white and black.

How do I color text in vuetify?

1 Answer 1. There are css classes for coloring text anywhere in vuetify, just append --text to a color. It should work with colors defined in your theme as well e.g. primary--text and similar. Note that this is not specific to a v-btn, class should work anywhere.

How do I change the font style in vuetify?

However you need to know which CSS classes to use in order to make the changes. Vuetify have already defined many CSS classes to control many style. For instance to change the font color to red you simply say class="red--text" or to change the typography or the fonts you can use one of the predefined font styles like this class="subtitle-2" .

How do I change the color of a vuetify card?

As you can see above, you can simply control the color, padding, alignment of the card component by just using few props without the need to use CSS at all Every Vuetify component comes with a very handy property called class . And you can use that class to change many styling props like the color, font, padding, alignment…


1 Answers

You can add a class to the app and create a more-specific CSS rule like so (this example doesn't actually run here, but you can copy it over to your codepen):

new Vue({
  el: '#app',
  vuetify: new Vuetify({
    theme: {
      dark: true,
      themes: {
        dark: {

          // Color is applied to selected drop down item
          primary: '#0064A2',
          
          // Uncomment this to make things worse
          // 'primary--text': '#FF00FF'
        }
      }
    }
  }),
})
.my-app.v-application .primary--text {
    color: white !important;
}
<div id="app">
  <v-app class="my-app">
    <!--Click the dropdown to see ugly colors-->
    <v-select :items="[undefined]"/>
  </v-app>
</div>
like image 172
Roy J Avatar answered Oct 17 '22 07:10

Roy J