Skip to content

[css-nesting] Allow custom property within nested at-rule conditions #8753

Description

@miragecraft

I believe the rationale against allowing custom properties was because custom properties are applied against elements, not at-rules that aren't attached to any element.

But now that we can nest at-rules inside selectors, shouldn't we then allow custom properties for nested at-rule conditions?

As for why we can't just use the proposed author env() variable, it's because we can't dynamically change it per element.

Example of a Flexbox component with dynamic breakpoint set via inline style (which is not possible with env()):

.flex {
  display: flex;
  container-type: inline-size;
  --breakpoint: initial; /* reset */
}
.flex > * {
  flex: 1;
  @container (calc($(--breakpoint) < width)) {
    flex-basis:100%;
  }
}
<div class="flex" style="--breakpoint:640px">
  <div>column</div>
  <div>column</div>
</div>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions