[Feature] Sort variants by variantOrder when unstable_stack is true #3289
anuraghazra
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The Problem
While building our component library we faced this issue #1951 but after trying out every solution with tailwind-override and tailwind-cascade they did not fit our needs.
Then we found this solution which worked like a charm #1446 (comment) which basically suggests to create a custom
base:
variant to handle the specificity issue.See `base:` plugin code
Now we want our variants to stack on top of other variants so we added the unstable_stack option in addVariant
Normally when
unstable_stack
is falsevariantOrder: ['base', 'DEFAULT']
will generate the following CSSWhich is what we want because we want the .bg-yellow-100 to override the .base:bg-blue-100.
but if we set
unstable_stack=true
tailwind does not follows thevariantOrder
and generates the following CSS which breaks the specificity.Solution
Make
unstable_stack=true
follow the variantOrder properly.I've did some experiments and this code does work :-
It sorts the remainingVariants by variantOrder.
file: https://github.com/tailwindlabs/tailwindcss/blob/master/src/lib/substituteVariantsAtRules.js#L184
Related PRs, Issues & Links:
https://tailwindcss.com/docs/configuration#variant-order
#1446
#1951
#657
#496
Beta Was this translation helpful? Give feedback.
All reactions