Re: [csswg-drafts] [css-mixins-1] Are @mixin rules valid within other at-rules? (#12417)

> My initial thought is that (for simplicity) we should make @mixin invalid within any at-rule except conditional rules with the "old school" processing model (i.e. currently `@media` and `@supports`).

I somewhat agree with this.

But I think mixin rules should also be valid in `@layer` rules to be able to use cascade layers to resolve name conflicts.

However the inner styles should not be affected by this I think.
I would expect `:root` to have `color` `green` in this example:

```css
@layer early-layer, later-layer;

@layer later-layer {
  @mixin --m() { /* later layer declaration wins */
    color: green;
  }
}

@layer early-layer {
  @mixin --m() {
    color: red;
  }
}

:root {
  color: pink;
}

:root {
  @apply --m(); /* inner styles are unlayered */
}
```

Authors can also layer inner styles by writing:

```css
@layer a {
  @mixin --m() {
    @layer b {
      color: green;
    }
  }
}
```


-- 
GitHub Notification of comment by romainmenke
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/12417#issuecomment-3019163069 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Monday, 30 June 2025 13:27:44 UTC