I have 2 menu's on a React project, both of which use NavLink to show whether it is active or not.
The normal one works, but the mobile one is build with the HeadlessUI Disclosure.Button...
So I have:
<Disclosure.Button
as={NavLink}
to='/'
className={({ isActive }) => isActive
? "bg-indigo-50 border-indigo-500 text-indigo-700 block pl-3 pr-4 py-2 border-l-4 text-base font-medium sm:pl-5 sm:pr-6"
: "border-transparent text-gray-500 hover:bg-gray-50 hover:border-gray-300 hover:text-gray-700 block pl-3 pr-4 py-2 border-l-4 text-base font-medium sm:pl-5 sm:pr-6"
}
>
My Events
</Disclosure.Button>
And the isActive boolean in this one just doesn't work.
I'm assuming that the className I use do not affect the NavLink, but only affects the Button? But I haven't a clue.
The issue isn't with the Router or anything, because the main manu up top works:
<NavLink
to="/"
className={({ isActive }) => isActive
? "border-indigo-500 text-gray-900 inline-flex items-center px-1 pt-1 border-b-2 text-sm font-medium"
: "border-transparent text-gray-500 hover:border-gray-300 hover:text-gray-700 inline-flex items-center px-1 pt-1 border-b-2 text-sm font-medium"
}
>
My Events
</NavLink>