Allow Container Query Classes on Container Elements #18240
nextweb-kim
started this conversation in
Ideas
Replies: 1 comment 1 reply
-
I believe the current behaviour is a limitation in CSS, not Tailwind. I don't think you can have a container query be relative to itself as that can cause infinite loops: <div class="@container @xs:w-0"> |
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: Allow Container Query Classes on Container Elements
Problem Statement
Currently, when using
@tailwindcss/container-queries
, container query classes (e.g.,@md: my-8
) cannot be applied to the same element that has the@container
class. This creates a significant limitation in practical layouts, especially when managing margins and spacing.Current Limitation
Required Workaround
Why This Matters
1. Margin Collapse Benefits
my-*
classes naturally maintain consistent spacing2. Component Reusability
3. Real-world Use Cases
Proposed Solution
Allow container query classes to be applied to container elements themselves, with the understanding that:
Alternative Approaches Considered
Impact
This enhancement would:
Example Use Cases
Thank you for considering this enhancement. Container queries are incredibly powerful, and this change would make them much more practical for everyday use.
Beta Was this translation helpful? Give feedback.
All reactions