Re: [csswg-drafts] [css-selectors] Reference selectors (#3714)

> In looking at the current status of `@sheet` and how it might export stylesheets, I wonder if an at-rule would be better for this.
> 
> Something like `@block`:

Given work has actually started [towards mixins](https://drafts.csswg.org/css-mixins/) it would probably make sense to just use those (no spec text for mixins yet, though [roughly outlined here](https://css.oddbird.net/sasslike/mixins-functions/#defining-a-mixin-the-mixin-rule)).

An advantage to mixins is they could even parameterized, which we could easily expose in JS as functions:

e.g.

```css
@mixin --color-blue {
    color: blue;
    /* ... */
}

@mixin --square(--size type(length)) {
    width: var(--size);
    height: var(---size);
}
```

```ts
import { "--color-blue" as colorBlue, "--square" as "square" } from "./sheet.css" with { type: "css" };

// Equivalent to if .styles had additional @apply rules
element.mixins = [colorBlue, square(CSS.px(100))];
```


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


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

Received on Tuesday, 11 February 2025 11:09:18 UTC