-
Notifications
You must be signed in to change notification settings - Fork 765
Open
Labels
Description
Container queries allow us to query a container for specific conditions, including values of custom properties through style() queries.
But they do not allow us to query the element itself.
In #10064 there is a proposal for inline conditions that do allow setting values conditionally when an element has a specific value. Implementers indicated that this would be possible
Can we have the same as an at rule?
I am assuming that this needs to be highly restricted as explained in #10064 (only style() queries with custom properties?)
.foo {
background-color: blue;
color: white;
border-radius: 2px;
@element style(--color: pink) {
background-color: pink;
color: black;
border-radius: 4px;
}
}This example would result in a pink background on any element with class .foo when it also has --color: pink.
Nested vs. not nested gives interesting possibilities:
/* style multiple variations for `.foo`: */
.foo {
background-color: blue;
@element style(--color: pink) {
background-color: pink;
}
@element style(--color: green) {
background-color: green;
}
}
/* style multiple variable elements: */
@element style(--color: green) {
.foo {
background-color: green;
}
.bar {
color: green;
}
}Benefits I see to this syntax:
- allows setting multiple declarations with a single condition
- values can be easily invalid at parse time
jonathantneal, brunostasse, bleper, paulmelero, kizu and 3 more