-
Notifications
You must be signed in to change notification settings - Fork 689
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
[css-extensions] Custom container queries #8121
Comments
Yeah, I have a similar sense that this:
|
The majority of my desire for custom media queries was so I could do If there's ever a js api for container queries that same want would arise. Although if the js api allowed style queries I could just listen for a custom property and set it to different sentinel values at the various component breakpoints. |
Thanks for submitting this, @romainmenke and to other for taking a look at it! @mirisuzanne I may be misunderstanding, but I was under the impression that It was seeming for a while that the custom query issue was perhaps going to be solved by allowing declaration of custom (if that is the main blocking issue, personally I'd be fairly satisfied if I could only declare them through a JS API, or possibly restrict in-CSS declarations to be simple, single values, but I guess others found those options unsatisfying?) |
@gabrielgrant - Unlike media queries, container queries are resolved against individual elements (the containers) – and can be resolved in that context. I cover that in more detail in the linked proposal. |
Container queries have landed in stable browsers and they are a huge milestone for web development. Unfortunately they are not supported yet when scoped: <style lang="postcss" scoped>
.container {
container-type: inline-size;
}
@container (min-width: rem(700)) {
.wrapper {
flex-direction: row;
}
}
</style> This is what we get: .wrapper[data-v-ec3ae8ce] {
display: flex;
flex-direction: column;
}
@container (min-width: 43.75rem)
.wrapper {
flex-direction: row;
gap: 1.875rem;
}
} This makes that the container query is not rendered because the class specificity is lower. |
@retroriff That seems like an issue in the framework or tool you are using. |
OK, I am using Nuxt. Thanks |
This was requested in csstools/postcss-plugins#671
It would be in parallel with
@custom-media
.I personally do think the benefits of having this are smaller than they are with
@custom-media
.The same media conditions are often re-used throughout an entire code base.
Assigning these to a named variable has obvious code quality benefits.
Container queries however are much more local.
They are more often tied to the code contained therein.
I can be wrong about this, this is purely my impression.
Maybe @mirisuzanne proposal to allow
var()
inside<container-condition>
is all authors need?The text was updated successfully, but these errors were encountered: