[css-contain-3] Support style() container queries
Categories
(Core :: CSS Parsing and Computation, enhancement)
Tracking
()
| Size Estimate | M |
People
(Reporter: bramus, Unassigned)
References
(Depends on 7 open bugs, Blocks 11 open bugs)
Details
(Keywords: parity-chrome, parity-safari, webcompat:platform-bug, Whiteboard: [platform-feature][webcompat:risk-high])
User Story
web-feature: container-style-queries user-impact-score:40
Steps to reproduce:
Spec: https://drafts.csswg.org/css-contain-3/#style-container
Spec still a draft right now. Filed this issue so thereβs something to track across all vendors.
- Blink/Chromium: https://bugs.chromium.org/p/chromium/issues/detail?id=1302630
- WebKit/Safari: https://bugs.webkit.org/show_bug.cgi?id=246605
Updated•2 years ago
|
Chrome has implemented style query of custom property values at version 111.
Webkit position is also supportive of the CSS variables use case: https://github.com/WebKit/standards-positions/issues/57#issuecomment-1691159042
Suggest to split the feature into variables usage and standard properties usage.
And Implement the CSS variables usage at first.
It maybe resolve some problems, even the another way for enviroment queries in shadow dom (Current supported with :host-context() in Chrome).
Update:
WebKit has enable Style queries by default WebKit/WebKit#24251
Updated•1 year ago
|
Updated•1 year ago
|
Safari 18 will enable it by default: https://developer.apple.com/documentation/safari-release-notes/safari-18-release-notes#CSS
Updated•1 year ago
|
Updated•1 year ago
|
Updated•11 months ago
|
Very very sad that this is not supported yet. (Along with a few others.)
Hope to get support for it soon, because I use it as part of a "scroll-triggered animations" hack. There's no workaround for it, I think.
PS: Nice to see you here Bramus!
CSS WG has resolved to drop :host-context(), and suggest using container style queries to replace its use cases.
So is it possible to raise it priority?
(In reply to Arun Das from comment #5)
Hope to get support for it soon, because I use it as part of a "scroll-triggered animations" hack. There's no workaround for it, I think.
There is no need for style queries for scroll-triggered animations. See this demo I made back in 2023.
For anyone itching to try style queries in Firefox, you can now set the layout.css.style-queries.enabled flag to true in about:config. I've just used it to set different pseudo content values depending on a computed modulo value and it worked.
Updated•5 months ago
|
Updated•4 months ago
|
Comment 8•3 months ago
|
||
Hello. I enabled the layout.css.style-queries.enabled flag and gave it a try, but it seems that switching custom properties based on state changes doesn't respond correctly.
Here's a sample.
https://codepen.io/tak-dcxi/pen/GgpojbL
In both Chrome and Safari, switching custom properties on hover works as expected.
Updated•3 months ago
|
Comment 9•2 months ago
|
||
Just wanted to drop by and state that I am also hoping for support for this to land in Firefox :)
I have tried setting the option layout.css.style-queries.enabled for my use-cases and that works without issues. I have found several use cases that I believe to be fairly nice (in a design system/component system use case)
- By having every flex container be a named container and setting custom properties indicating flex-flow attribute, I can create semantic classes for stretching vertical/horizontal, that will do what the user would expect. It is especially nice here as this would require different properties to be set depending on the flex-flow property, which is nicely handled here.
- Propagate information regarding the "size" of the current UI element being rendered, and make components that alter their size based on this. Of course this can be done by adding lots of custom properties indicating the size of various elements, but doing it this way I find much more composable.
In general I find it to be a nice way of passing "context" through the stylesheets much the same way as one would use context in react components, and style queries in container queries lets me avoid storing quite a bit of context in javascript and push it down to CSS instead.
I don't know if having these sorts of use cases are of value or not, hope it is not unwanted noise here.
Updated•2 months ago
|
Updated•2 months ago
|
Updated•1 month ago
|
Updated•1 month ago
|
Updated•1 month ago
|
Updated•1 month ago
|
Description
•