Skip to content
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

[mediaqueries-5] Allow comparators / ranges in style queries #11759

Open
bramus opened this issue Feb 21, 2025 · 1 comment
Open

[mediaqueries-5] Allow comparators / ranges in style queries #11759

bramus opened this issue Feb 21, 2025 · 1 comment

Comments

@bramus
Copy link
Contributor

bramus commented Feb 21, 2025

The syntax of a <style-feature> is currently defined as “ a valid declaration, a supported CSS property, or a <custom-property-name>.”

The first part allows one to only do equality comparisons, like so:

/* --num-children is exactly 10 */
@container style(--num-children: 10) {
  #target {
    background: red;
  }
}

What is currently not allowed is to do mathematical comparisons, which I think would be nice to add, allowing authors to do things like this:

/* --num-children is 10 or greater */
@container style(--num-children >= 10) {
  #target {
    background: red;
  }
}

Or even this:

#target {
  background: if(
    style(--num-children >= 10): red;
    style(--num-children >= 8): orange;
    style(--num-children >= 6): yellow;
    else: green;
  );
}

(Assuming if() treats multiple conditions as if they were an else if – if not then the lines need to be reshuffled a bit)

Or this:

#target {
  background: if(
    style(--num-children >= 10): red;
    style(8 <= --num-children < 10): orange;
    style(6 <= --num-children < 8): yellow;
    else: green;
  );
}
@yisibl
Copy link
Contributor

yisibl commented Feb 21, 2025

I remember mentioning this syntax in other issues before, but I can't find it.

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

2 participants