Replies: 2 comments
-
There have been suggestions about adding such a feature. The maintainers have addressed this request before, that you may wish to read up on if you have not already done so: |
Beta Was this translation helpful? Give feedback.
-
@kefahB I think wrote some code that seems like it responds to your problem - https://www.npmjs.com/package/vite-plugin-twneat . I have the same problem too. Even in writing very simple landing pages, the mental strain of staring at tiny font "md:" "sm:hover:group" and how they interact and inherit up and down screen sizes, its really tough for me. Then a lot of past discussions were for v3 and not for v4 - so that adds even more confusion as v4 is a very big change without plugins, safelists, the js config file etc. Any feedback would be appreciated! It probably has bugs and not very performant, but the code is fairly straightforward - it just concats things and dumps it in a safelist. I am not sure but I don't think it produces more classes than what you would have written natively without groupings. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Problem Statement
Tailwind CSS is an amazing framework for utility-first styling, but its responsive syntax can sometimes feel repetitive and cluttered. When using multiple responsive utilities (sm, md, lg, etc.), we must prefix every individual class, leading to longer and less readable code.
Proposed Solution: Grouped Responsive Syntax
Instead of repeating the same prefix for each class, why not group responsive utilities together under a single breakpoint?
Example Comparison
Current Approach (Verbose & Repetitive)
Proposed Approach (Cleaner & More Readable)
How It Works
Benefits
✅ Improved Readability – No more repeating sm:, md:, etc., multiple times.
✅ Less Code Duplication – Write fewer lines while achieving the same styling.
✅ Easier Maintenance – Quickly update styles without searching for multiple occurrences of the same breakpoint.
✅ More Logical Grouping – Styles are visually grouped by breakpoints, making it easier to understand the structure.
Challenges & Considerations
Conclusion
This feature could revolutionize Tailwind CSS’s readability and maintainability, making it even more developer-friendly. However, it would require changes to the Tailwind compiler to support grouped utilities. Would love to hear thoughts from the Tailwind community! 🚀
Discussion Questions
Beta Was this translation helpful? Give feedback.
All reactions