I tried using thelinkExactActiveClass
parameter in the router constructor to highlight active links in the navigation bar.
My problem is that the active class is added to the beginning of the css class list, which means other classes override it.
const router = createRouter({ history: createWebHistory(process.env.BASE_URL), routes, linkExactActiveClass: 'text-yellow-500', });
router-link
The elements look like this:text-yellow-500
classes are indeed added before existing css classes. This causes the yellow text to be overwritten by thetext-white
class. How can I change this?
A simple solution is to use tailwind(documentation) in the class
Try using it like this:
Normally, I don't like this approach, but I don't think there is any other easy option
PS: Make sure you are using at least tailwind 2.1 andJITmode