Modifying the hover color in Vuetify 3

Within the AppBar.vue component of my Vuetify 3 project, I have noticed a very dark hover effect on the hamburger icon and menu items.

In the official documentation, it mentions that the default hover color should be a light grey, not full black. Can anyone explain why this unexpected change has occurred and suggest how I can adjust it?

I have experimented with various CSS selectors and pseudo-selectors, including using !important and wrapping the element in v-hover set to disabled...

https://i.sstatic.net/k0Ply.png

https://i.sstatic.net/OOjOI.png

<template>
  <v-app>
    <v-app-bar :elevation="2">
      <!-- eslint-disable-next-line vue/valid-v-on -->

      <v-app-bar-nav-icon @click="drawer = !drawer"> </v-app-bar-nav-icon>
      <v-app-bar-title>The Candidate Consultants</v-app-bar-title>
    </v-app-bar>
    <v-navigation-drawer v-model="drawer" app>
      <v-list>
        <v-list-item
          class="custom-hover"
          v-for="item in menuItems"
          :key="item.title"
          @click=""
        >
          <v-list-item-title>{{ item.title }}</v-list-item-title>
        </v-list-item>
      </v-list>
    </v-navigation-drawer>
  </v-app>
</template>

One of the CSS selectors I have tested is:

@import "@/styles/_variables.scss";
.custom-hover:hover {
  background-color: $blue !important;
}

Answer №1

I encountered a similar issue in the theme department, and the solution turned out to be quite simple:

import 'vuetify/styles';

In my vuetify.ts file, I defined the themes and options to inject into useVuetify. Surprisingly, this import is not clearly mentioned in the documentation.

This small addition completely transformed the layout to function as intended, affecting not just hover effects but everything else too.

Answer №2

It seems like the issue arises when there is no specific theme applied, causing unexpected behavior in your case.

The hover effect is targeted at an element with the *__overlay class, and it is determined by its opacity value controlled by the variables --v-hover-opacity and --v-theme-overlay-multiplier, as shown below:

v-list-item:hover > .v-list-item__overlay {
  opacity: calc(var(--v-hover-opacity)*var(--v-theme-overlay-multiplier));
}

These variables are supposed to be defined within the theme itself:

.v-theme--light{
  --v-hover-opacity: 0.04;
  --v-theme-overlay-multiplier: 1;
}

If necessary, you could manually set these variables, but it might be more beneficial to troubleshoot why your theme is not functioning properly. Any insights into what could be causing this discrepancy?

Additionally, when incorporating your code snippet, everything appears to be working correctly:

const { createApp, ref } = Vue;
const { createVuetify } = Vuetify
const vuetify = createVuetify()
const app = {
  setup(){
    return {
      drawer: ref(true),
      menuItems: ref([{title: 'item 1'}, {title: 'item 2'}])
    }
  }

}
createApp(app).use(vuetify).mount('#app')
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/vuetify@3/dist/vuetify.min.css" />
<link href="https://cdn.jsdelivr.net/npm/@mdi/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="91f7feffe5d1a4bfe9">[email protected]</a>/css/materialdesignicons.min.css" rel="stylesheet">
<div id="app">
  <v-app>
    <v-app-bar :elevation="2">
      <v-app-bar-nav-icon @click="drawer = !drawer"> </v-app-bar-nav-icon>
      <v-app-bar-title>The Candidate Consultants</v-app-bar-title>
    </v-app-bar>
    <v-navigation-drawer v-model="drawer" app>
      <v-list>
        <v-list-item
          class="custom-hover"
          v-for="item in menuItems"
          :key="item.title"
          @click=""
        >
          <v-list-item-title>{{ item.title }}</v-list-item-title>
        </v-list-item>
      </v-list>
    </v-navigation-drawer>
  </v-app>
  
</div>
<script src="https://unpkg.com/vue@3/dist/vue.global.prod.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vuetify@3/dist/vuetify.min.js"></script>

Answer №3

To customize the appearance of the v-list-item__overlay class, adjust the background color to reflect your desired primary color with added opacity:

<style lang="scss">
   .v-list-item__overlay {
      background-color: custom-theme("colors.primary.600") !important;
   }
</style>

In case you are utilizing

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Innovative idea for a time management system based on timelines and scheduling

My latest project involves creating a scrollable scheduler, inspired by vis-timeline and built using Vue.js. One of the main challenges I'm facing is achieving smooth infinite scrolling in all directions (past and future). I must confess that I&apo ...

Tips for resizing an image to fit within a col-sm-12 column in Bootstrap

I have a dilemma with two columns - I want to place my image in the first column so that the second column can move down. see image here Here is my HTML code: <div class="container-fluid"> <div class="row"> ...

How to initialize data in Vue.js components

I'm working on a Map.vue component and I need to update its data in Vue.js. However, I'm struggling to figure out how to do this: <template> <div> <div class="google-map" :id="mapName"> </div> </div> < ...

Creating a personalized input slider: A step-by-step guide

I have a question about how to design a custom input slider with the label inside the field itself. The desired output should look like the screenshot below: https://i.sstatic.net/gE6EJ.png I have successfully created the input field part, but I am stru ...

Concern regarding the lack of timely response

I am experiencing an issue with the responsiveness of my template. When I test it online on various websites, everything appears to be working perfectly. However, when I try to view it on my HTC one, the responsiveness is terrible and not fully functional. ...

The HTML Search Bar is Misaligned

once more. I seem to be having trouble with my search bar, as it is not appearing in the position or size that I coded for it. The search bar should look like the one shown in this link: https://www.w3schools.com/howto/howto_css_searchbar.asp However, ...

Retrieve vue environment variables within a template

I am trying to figure out how to access my environment variables directly from the template of Vue single file components. When attempting to do so like this: <img :src="`${process.env.VUE_APP_API_BASE_URL}/image/${image.filename}`" alt=" ...

Having trouble updating the icon on my website using FontAwsome

Just a heads up - I'm not familiar with HTML/CSS/JS. This template is pre-made, and I'm simply making some adjustments to it. Hello, I'm currently working on my portfolio website and I want to display my projects based on the programming la ...

"Utilizing social links in web design for a seamless user experience

I'm currently exploring ways to repair the design of social media links. The GitHub and Spotify icons are displaying at different sizes, and it seems like the Blogger icon is not aligning correctly: https://i.sstatic.net/7j4Hr.jpg Referring to How ...

Changing the image source when clicking on it and removing it can be done by using JavaScript

How can I add a class 'selected' to ".swiper-slide" when it is clicked? I also want to change the image src when svg-img1, 2, or 3 is clicked. However, I need the image to revert back to its default src when another swiper-slide is clicked. ...

Design: Seeking a layout feature where one cell in a row can be larger than the other cells

To better illustrate my goal, refer to this image: Desired Output <\b> Currently, I'm achieving this: current output Imagine 7 rows of data with two columns each. The issue arises in row 1, column 2 where the control needs to span 5 row ...

The project is experiencing difficulties in loading the Module CSS

Currently, I am working on a React module and have set up a React project to demonstrate the functionality of this module. Initially, everything was working smoothly until I encountered an issue with the webpack configuration related to the CSS loader. { ...

How should I properly initialize my numeric variable in Vue.js 3?

Encountering an issue with Vue 3 where the error message reads: Type 'null' is not assignable to type 'number'. The problematic code snippet looks like this: interface ComponentState { heroSelected: number; } export default define ...

The issue of Bootstrap icons not displaying on the front-end arises when integrating them into a Vuejs Template

I'm in the process of constructing a web application using Vue.JS. I've integrated the [Bootstrap Icons][1] into my application, but for some reason, the icons are not showing up on the screen. Here are the steps I followed: Installed Bootstrap ...

Showing a Bootstrap.vue b-table containing nested arrays within arrays

I am facing an issue while trying to display data in a b-table. Normally, it works well with most data sets. However, when I encounter another array nested within the referenced array, the rendering is not done properly. While working on this problem, I ...

List items not appearing inline

I'm having an issue with displaying a list of movies from my database. Instead of showing inline as intended, they are appearing vertically. I've tried using both inline-block and inline for the li elements, but so far nothing has worked. Any ass ...

Issue with CSS style on header with hyperlink

My CSS style includes a hyperlink for the "Title" to quickly navigate back to the home page. However, when I insert a table, this hyperlink gets disabled. /* JavaScript */ .header { position: absolute; height: 85px; right: 0; top: 0; left: 0; padding: ...

Emulate the Dynamics CRM Website

One of my clients is in need of a personalized page integrated into Microsoft Dynamics CRM. The task at hand may seem simple, as it involves embedding an iFrame. But here's the catch - my client is very particular and expects the embedded page to sea ...

Elevate the HTML dropdown above all other elements on the page

Currently, I am utilizing a dropdown widget from http://www.w3schools.com/ : <div class="dropdown"> <button onclick="myFunction()" class="dropbtn">Dropdown</button> <div id="myDropdown" class="dropdown-content"> <a href= ...

Include a flexible div in the hero section and change the position when resizing the screen

Looking to achieve a specific layout with only two resolutions in mind (767px minimum and maximum). For screens larger than 767px, display two divs side by side: one with text on the left and the other with an image on the right. The text remains in a fi ...