Skip to content

[css-contain-3][css-mediaqueries-5] Unified custom queries #7622

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

Open
Que-tin opened this issue Aug 18, 2022 · 2 comments
Open

[css-contain-3][css-mediaqueries-5] Unified custom queries #7622

Que-tin opened this issue Aug 18, 2022 · 2 comments

Comments

@Que-tin
Copy link

Que-tin commented Aug 18, 2022

The spec for Media Queries Level 5 currently specifies a way to define custom media properties like e.g. @custom-media --modern (color), (hover); with CSS Containment currently getting shipped beforehand, wouldn't it make sense to rename @custom-media to @custom-query, to create a reusable and unified way for creating custom properties that are including a query?

I mean if I get the idea of the current draft correctly, values inside of @custom-media could also be used inside of @container and @supports as well. But these aren't media, but feature & containment / container or even style queries.

Proposed @custom-query Solution

@custom-query --narrow-size (inline-size > 30em);
@custom-query --full-grid-support (display: grid) and (grid-template-columns: subgrid;);
@custom-query --is-special style(--is-round: true) and style(--is-highlighted: true);
@custom-query --combined-media-query-list (--narow-size), (--is-special);

@media (--narrow-window) {
 ...
}

@container card (--narrow-window) {
 ...
}

@container card (--is-special) {
 ...
}

@container card (--combined-media-query-list ) {
 ...
}

@supports (--full-grid-support) {
 ...
}

If from a technical stand point it isn't possible to get a unified solution for queries, this is a proposal for reusable custom-queries for supports & container, e.g. @custom-container fand @custom-supports.

@Que-tin Que-tin changed the title [css-contain-3][css-mediaqueries-5] Custom container queries [css-contain-3][css-mediaqueries-5] Unified custom queries Aug 18, 2022
@valtlai
Copy link
Contributor

valtlai commented Aug 19, 2022

Related: #6698 (using custom env() variables in media queries)

@Que-tin
Copy link
Author

Que-tin commented Jun 8, 2025

Following recent discussions on this topic, I'd like to bring this topic back into focus

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants