Proposal: Grouped Variant Utility Classes with Pipe Syntax (hover:|...|, sm:|...| dark:|...|) #18629
hassanullahusmani45
started this conversation in
Ideas
Replies: 2 comments 1 reply
-
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.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Feature Request: Grouped Utility Class Syntax Using Pipes (|...|) for Variants
Summary
Tailwind CSS provides a powerful and expressive system using variants like sm:, hover:, dark:, focus:, etc. However, when combining many variants and multiple utility classes, the resulting class attribute becomes cluttered and hard to read or maintain.
I propose a grouped variant syntax using pipes |...| to improve readability, reduce repetition, and logically group classes under a single variant prefix.
💡 Proposed Syntax
Example:
Benefits
✅ Much cleaner class attributes when using multiple variants.
📚 Improved readability, especially with long class lists.
🧠 Logical grouping helps developers spot which styles apply under which condition.
🧑💻 Better DX (developer experience) during authoring and reviews.
💡 Works naturally with all variants: hover:, focus:, group-hover:, dark:, disabled:, aria-..., etc.
Beta Was this translation helpful? Give feedback.
All reactions