0

I am trying to change the color of the dropdown background of a v-menu. Right now it is just white then in dark mode it is that dark gray.

I have tried the css override using this:

.v-menu__content { background-color: var(--v-success-base) !important; }

But this is not working no matter what I try. I am also using the: content-class in the v-menu but this doesn’t work either.

Is this even possible and should I just use a different solution than a app bar button opening this v-menu?

1 Answer 1

0

You can style the underlying v-list in a v-menu by using :content-props and the CSS Variable --v-theme-surface which is used internally by v-list's SaaS variables.

First define a CSS rule to change the background color variable:

.success-content {
  --v-theme-surface: 25, 135, 84;
}

Be careful ❗️ Color CSS variables will most of the time only take numbers and not colors directly ; while the previous CSS rule works, the following will not:

.success-content { /* Will not work! */
  --v-theme-surface: rgb(25, 135, 84);
}

After creating your CSS rule, you can then apply it to your v-menu :

<v-menu
  ...
  :menu-props="{
    contentClass: 'success-content',
  }"
>

Here is a demo on VPlay.


You can also use custom theming to generalise those styles and reuse them in other places in your code, and also use attached or detached styles. For more details, you can check this answer to a similar styling question using Vuetify

Wish you good luck with your project !

2
  • 1
    That worked perfectly…..although I will need to find a way to make it follow the dark/light theme. I scoured the internet and used GitHub Copilot and Chat GPT and neither of them suggested this. Thank you very much Ivan
    – VVaFF
    Commented Apr 6 at 19:07
  • Better to just use <v-list bg-color="success"> Commented Apr 8 at 3:45

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