Expand named container queries to all variants (@max-value/name, @min-value/name, etc.) for semantic clarity and modular extensibility #19281
selcukcukur
started this conversation in
Ideas
Replies: 1 comment 1 reply
-
|
This is already supported in Tailwind as per this Tailwind Play:
|
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.
-
Summary
Tailwind CSS currently supports named container queries in breakpoint-based forms such as
@container name (width >= value)and@container @sm/name. This proposal advocates for extending named query support to range-based variants—including(width < value),(width >= value), and compound expressions—so that named containers can be used consistently across all container query types. This unlocks semantic clarity, modular trait composition, and teardown-safe architecture across layout systems.Motivation
🧠 1. Semantic Clarity Across All Query Types
Named container queries like
sidebar (width < 768px)orcard (width >= 640px)offer immediate semantic context. This improves readability, contributor onboarding, and trait-scoped documentation—especially in large-scale design systems.🧩 2. Trait Modularity and Teardown Safety
Named queries allow traits to be grouped by semantic domain (e.g.,
Flex Layout,Spacing,Sidebar,Card) and exported teardown-safely. This aligns with Tailwind’s utility-first philosophy while enabling sugar-style documentation and contributor-friendly exports.🔄 3. Consistency Across Query Syntax
While breakpoint-based named queries (
@container @sm/name) are supported, range-based queries ((width < value),(width >= value)) currently lack named support. Extending named support to these variants ensures architectural symmetry and avoids edge-case confusion when composing responsive traits.Currently Supported
Proposed
Technical Considerations
🔍 Parsing Strategy
name (width < value)andname (width >= value) and (width < max-value)into internal query maps for consistent resolution.✅ Backward Compatibility
🛠 Developer Experience Enhancements
Ecosystem Impact
Closing Thoughts
Expanding named container query support to range-based variants is a low-risk, high-impact enhancement. It strengthens Tailwind’s semantic backbone, empowers contributors, and unlocks expressive layout strategies that scale across teams and ecosystems.
Let’s make container queries as modular, semantic, and intuitive as the rest of Tailwind.
Beta Was this translation helpful? Give feedback.
All reactions