I'm trying to set and active/inactive link state in a navbar built with tailwind. I'm sending a prop based on the url (ActiveLink).
What i'm trying to achieve is something like this:
<a href="/test" :class="{active(): ActiveLink == 'test', inactive(): ActiveLink !='test' }">Test</a>
<a href="/test2" :class="{active(): ActiveLink == 'test2', inactive(): ActiveLink !='test2' }">Test</a>
with active/inactive methods returning the classes that need to be applied Instead of printing this
<a href="/test" class="active">Test</a>
active() {
return "px-3 py-2 rounded-md text-sm font-medium text-white bg-gray-900 focus:outline-none focus:text-white focus:bg-gray-700"
},
inactive() {
return "mt-1 block px-3 py-2 rounded-md text-base font-medium text-gray-300 hover:text-white hover:bg-gray-700 focus:outline-none focus:text-white focus:bg-gray-700"
}
I think i'm heading down the wrong path with :class= but can't seem to find the right alternative