Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to style the background color and size of a v-list in Vuetify?

enter image description here

I'm new to Vuetify and would like to make something like this. Basically I have a navigation drawer as a side bar and I want to be able to change the background-color of one of the list on hover as well when selected. Vuetify documentation doesn't seem to discuss this. And I've been looking everywhere, any help will be appreciated.

like image 357
FledglingDeveloper Avatar asked Jan 14 '19 02:01

FledglingDeveloper


People also ask

How do you add a background color on Vuetify?

To set background color with Vuetify, we can add our own theme colors. import Vue from "vue"; import Vuetify from "vuetify/lib"; import colors from "vuetify/lib/util/colors"; const vuetify = new Vuetify({ theme: { themes: { light: { primary: colors. purple, secondary: colors. grey.

How do I change my Vuetify theme color?

This can be easily changed. Simply pass a theme property to the Vuetify constructor. You can choose to modify all or only some of the theme properties, with the remaining inheriting from the default. You can also use the pre-defined material colors.

How do I change the text color in Vuetify?

Changing text color and background color is easy with Vuetify, too. For the background color, simply add the name of the required color to the element's class. For text color, just add the color name followed by --text .

What is V list tile?

The v-list component is used to display information. It can contain an avatar, content, actions, subheaders and much more. Lists present content in a way that makes it easy to identify a specific item in a collection. They provide a consistent styling for organizing groups of text and images.


1 Answers

You can assign the "v-list-tile", which is the bit you want to style, a class and include your css in that. So your v-navigation-drawer html will look like this:

<v-navigation-drawer
      dark
      permanent
    >
      <v-list>
        <v-list-tile
          class="tile"
          v-for="item in items"
          :key="item.title"
          @click=""
        > 
          <v-list-tile-action>
            <v-icon>{{ item.icon }}</v-icon>
          </v-list-tile-action> //etc....

As you can see I have added the class="tile" to the "v-list-tile".

Now just add a .tile class to your pages css:

<style scoped>
  .tile {
    margin: 5px;
    border-radius: 4px;
  }
  .tile:hover {
    background: green;
  }
  .tile:active {
    background: yellow;
  }
</style>

and that should do the job.

like image 125
Andrew1325 Avatar answered Sep 28 '22 09:09

Andrew1325