activeProps Paintpoint for classname priority
So i'm setting up navigation and noticed i'm running into a painpoint with the
activeProps concept and class name order. for example, if i have something like this:
text-primary will get added but will not take priority because text-secondary-foreground beats it out because i can't include it in my cn() on my regular classname.
i have a couple ideas here, but not ideal to have to come up with a workaround here. anyone else run into something like this before?8 Replies
stormy-goldOP•3y ago
wonder if it would be reasonable to just have
activeProps.className take priority over regular className @Tanner Linsley 🤔
actually nvm. even as above the prop is technically after but can't win out
best option i have right now is something like the below, which works, but still isn't ideal so wanted to call it out
e
oo just notice you have data-status -- is this reliable enough to use in this case?
yeah it does work. if anyone runs into this and is curious i'm running with the below unless tanner calls it out as unstable
automatic-azure•3y ago
or you can use router state or urlparams and see if active and do a conditional with cn that could work fine @pdevito3
stormy-goldOP•3y ago
Hmm. Then I’d be reimplementing that active derivation though @Bachitter
ugly-tan•3y ago
I think it's just a subject of class specifity and order of classes in Tailwind stylesheet and it's not solvable at the library level. I'm personally just using
inactiveProps and activeProps together to apply classes that would conflict with each other. and standard className only to apply shared classes. Something like this:
Using data status is also fine and intended for usage afaik, E.g. I'm using it to style child elements based on Link activeness. I'm finding activeProps inactiveProps combo easier to handle for the Link itself stylingautomatic-azure•3y ago
yeah
provincial-silver•2y ago
@Paweł Błaszczyk How can you check for the data status for child components, and not the Link component?
ugly-tan•2y ago
I've used Tailwind
group feature for this onewise-white•2y ago
I've just been using
[.active]:token
Is that not enough?