0

I am trying to change the default color of anchor elements in the navbar. It works well, but when I try to do the same for the hover state of the element, it does not work:

  • Here you can see the custom link: enter image description here

  • And here the link when hover: enter image description here

I want to keep the current background color when hover but change the text color to 'text-primary'.

My current situation is:

<div class="navbar-start hidden lg:flex">
        <ul class="menu menu-horizontal px-1">
            <li class="text-primary hover:text-primary"><a class="hover:text-primary">Home</a></li>
            <li class="text-primary"><a>Realisations</a></li>
            <li class="text-primary"><a>Contact</a></li>
        </ul>
    </div>

As you can see I only tried something on the home button. Thanks for help

Auloma
  • 101
  • 1
  • 8

1 Answers1

2

Consider using the !important modifier to ensure the Tailwind class applies:

<div class="navbar-start flex">
  <ul class="menu menu-horizontal px-1">
    <li class="text-primary"><a class="hover:!text-primary">Home</a></li>
    <li class="text-primary"><a>Realisations</a></li>
    <li class="text-primary"><a>Contact</a></li>
  </ul>
</div>

See this working in Tailwind Play.

Wongjn
  • 8,544
  • 2
  • 8
  • 24