Group pseudo-selections, e.g. lg:(style-one style-two) #2764
Replies: 6 comments 1 reply
-
This is a suggestion that keeps coming up and rightfully so. |
Beta Was this translation helpful? Give feedback.
-
Something like
Spaces in class attribute's value will create new classes |
Beta Was this translation helpful? Give feedback.
-
We prototyped this to test the performance a little while ago. Because every unique combination of utilities is a new class, this means tons of duplicate CSS compared to using individual utilities: We tested it on the Tailwind UI codebase (probably biggest Tailwind codebase on earth) and our tests show that always using grouping doubles the CSS bundle even after compression: It means less content in your HTML though right, since the classes are shorter. So we benchmarked the file size of each HTML file as well: The surprising thing here was that even though the HTML files are smaller before compression, they are actually bigger after compression than just using ungrouped utilities. This makes sense when you think about it, because using the grouped syntax (like So overall even though this feature may be a DX improvement, it's a big performance anti-pattern so we are a little hesitant to include it. It makes all of your files larger and your site slower. |
Beta Was this translation helpful? Give feedback.
-
I personally believe the best solution to this problem is a third party plugin for your particular build system for handling this in a compile step before Tailwind picks it up. That provides the DX benefits without the downsides noted above. |
Beta Was this translation helpful? Give feedback.
-
Can CSS Nesting solve any of these problems? |
Beta Was this translation helpful? Give feedback.
-
or example, you can use lg:{flex p-10} or lg:[flex p-10]. Why, for example, when compiling, just do not divide by lg:flex and lg:p-10. damn, well, it can be thought out somehow. Why, for example, md:flex md:p-10 does not prescribe 2 media requests? Probably because it is somehow implemented under the hood. I think there are a lot of ideas to come up with here and I would really like this feature to be added and then tailwind would have no equal |
Beta Was this translation helpful? Give feedback.
-
Hey there.
Wondering if it's possible to add a feature that allows writing this
to be equivalent to this
It would save some keystrokes and be easier to read.
Let me know if there's anything I can do to help.
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions