-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Calc is not supported as an [arbitrary] container size #5
Comments
Just a note for when we get back from the holidays — I'm guessing this is because it becomes hard to sort, and we need variants to sort deterministically in the resulting stylesheet for your site to render as expected. We are probably dropping this value completely because we're interpreting it as unsortable, which is maybe not actually true as long as only one unit is used in the calculation. |
Correct @adamwathan, we explicitly parse the value and check for numbers so that we can guarantee sorting. We could make this a bit more flexible as you mentioned if you are using the same unit but that breaks down fairly quickly if you start using Maybe we can apply some different sorting heuristics:
|
Hey! Apologies on the delay here. I've been catching up on older issues this week and finally had a chance to dig into this one a little deeper. Unfortunately there isn't a reliable way for us to support When it comes to media and container queries, order matters a lot, as the styles defined later in the CSS take precedence over those defined earlier. Tailwind uses this to it's advantage with it's mobile-first approach to responsive design, where larger screen size variants take precedence over smaller ones. You can read more about that here: https://tailwindcss.com/docs/responsive-design Since Tailwind works this way, we automatically sort media queries (defined in your config) by their screen size — smallest to largest. However, if you happen to include raw media queries in your config, or if you're using mixed units (ie. both Further, if you use the You can read a detailed explanation of why it works this way here: tailwindlabs/tailwindcss#9558 (comment) These exact same challenges exist with the container queries plugin. Yes, if you were writing raw CSS you could use We also can't rely on the order in which the container query variants are detected, as this can easily change depending on your content — as you add, remove or change files. And, even if that wasn't an issue, this would still very likely lead to the incorrect sorting of the container queries styles, as it would simply be based on what class was found first, and not based on smallest to largest values. Further, since we're talking about arbitrary values here and not values from the config, we can't even rely on the order that they were defined in your config, as they don't exist there. For all these reasons we currently throw away arbitrary container query sizes that we cannot sort: tailwindcss-container-queries/src/index.ts Lines 34 to 37 in c287ac7
We technically could update this plugin to not do this, but then we'd, of course, have to decide how to sort these values, which there is no reliable way of doing. Here's an example Tailwind Play that does exactly this, which you're totally welcome to use, but you'll notice that the outputted CSS for the arbitrary container query sizes doesn't make sense: https://play.tailwindcss.com/eaHjt6LxxS So in conclusion, as far as I can tell, there just isn't a great way to support using I hope that explanation was helpful. |
What version of @tailwindcss/container-queries are you using?
0.1.0
What browser are you using?
Chrome 108.0.5359.125
What operating system are you using?
Windows
Reproduction repository
https://play.tailwindcss.com/ZJqWpcCdgG
Describe your issue
I would like to use
calc
as the container size. This works in CSS, but doesn't work in Tailwind.https://chromestatus.com/feature/5643732019838976 - a grain of information as to why this should work.
CSS version works in Chrome 108, Firefox 110 Nightly (stable does not support CQ yet), Safari (some of the latest version).
The text was updated successfully, but these errors were encountered: