-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CSS rules of the form .foo.bar
don't behave as expected with peer-checked:bar
#9056
Comments
Hey! Can you share a more real-world example of why you would even be doing this? I agree the behavior doesn't feel right here but the usage looks really bizarre to me ( |
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
Sorry for the delay, I've been on holiday for the last couple of weeks. Our use case is admittedly a bit weird and complicated so I'm not surprised it hasn't really been an issue. We have a "visual check box" component where we control how it appears using CSS classes, e.g. adding the This works really well and allows us to create custom components that are controlled entirely by CSS, no JS involved. However, if we want to render a checked and disabled checkbox ideally we would define the style using a Note that we use this in various different situations not just with |
Hey, I just merged in the fix for this. It'll be in our next tagged release. If you want to try it before then you can test our insiders build: |
I haven't had time to investigate this fully, however I suspect this won't achieve exactly what I needed (it's still a good improvement though). My original CSS looked something like this: @layer components {
.checkbox--unchecked {
@apply bg-white;
}
.checkbox--checked {
@apply bg-blue-600;
}
.checkbox--disabled {
@apply bg-gray-100;
}
.checkbox--disabled.checkbox--checked {
@apply bg-gray-300;
}
} The important part here is the "disabled and checked" colour is different from both the "enabled and checked" and "disabled and unchecked" colours. In order for it to work correctly with just .peer:checked:disabled ~ .peer-checked\:checkbox--checked.peer-disabled\:checkbox--disabled {...} Which seems very complicated, is a niche use-case, and has the danger of causing an exponential explosion in the number of rules Tailwind generates (it would have to generate a rule for every combination of prefixed The only way I could see this maybe being implemented is something like |
Yeah in this case you're trying to match a "single utility" made of multiple classes but NOT utilities made of the individual classes. We cannot do this generally and it would require a specialized feature. This is explicitly not something we would support. We encountered a similar case with The only real way I can think of is to:
|
What version of Tailwind CSS are you using?
v3.1.8
What build tool (or framework if it abstracts the build tool) are you using?
postcss-cli 10.0.0
What version of Node.js are you using?
v16.14.0
What browser are you using?
N/A
What operating system are you using?
Linux
Reproduction URL
https://play.tailwindcss.com/4zvuUG5xci
Seems Tailwind Play is still on v3.1.5, but I see the issue in v3.1.8
Describe your issue
If I have a standard CSS rule defined like this:
Then I would expect
peer-checked:bar
to define the following:Instead it generates:
.foo
is applied to the.peer
instead of the.peer-checked\:bar
.Changing the original rule to
.bar.foo
fixes the issue (i.e. it works as expected with the first class in the list).The text was updated successfully, but these errors were encountered: