It would be nice to also see a container() function as a leaf of the @when rule, in addition to the already specced media() and supports() functions.
The syntax would preferably be the same as the @container rule:
container() = container( [ <container-name> | [ name(<container-name>) || type(<container-type>+) ] ]? <container-query> )
(Perhaps the optional part should not be optional here, for performance reasons? 🤔)
Use case: it would allow stuff such as easy dark mode toggling based on the value of a custom property on a style container:
@when media(prefers-color-scheme: dark) or container(root style(--color-scheme = dark)) {
body {
--primary-color: #efefef;
--primary-bg-color: #333;
}
}