Re: [csswg-drafts] Multiple stylesheets per file (#5629)

> Right now nothing is exported from a style sheet to JS except for the sheet itself in the default export. `@sheet` as proposed would be the first thing to create a named export.

> I have been concerned about needing to know which things create named exports as that set expands in the future. How would we export class name, and would that use something like `@export` or a new at-rule for declaring a class name or selector, and that new rule creates a named export?

I am unsure if this is the correct framing/perspective.

I am not in favor CSS syntax that only exists so that it makes something work on the JS side.
So it doesn't make sense to me to have to add extra syntax in a stylesheet to make things accessible from JS.

Can't we have good JS API's to access various parts of a stylesheet?

`@sheet` also isn't really an export as I see it.
It is a named thing, in the same way that `@keyframes FOO {}` is a named thing.
And these named things can be accessed from JS.

As @bramus also notes we have specs for `@custom-selector`, but also `@property`, `@custom-media`, ... These could have convenience API's on the JS side to easily extract them.

-----

I am not really in favor of this syntax:

```js
import {sheet1, sheet2} from './styles1and2.css' assert {type: 'css'};
```

I would prefer something less magical:

```js
import sheet from './styles1and2.css' assert {type: 'css'};

const sheet1 = sheet.getSheet('sheet1'); // or any similar API to get the sheets from the `CSSStyleSheet` object.
```

In a way `import {sheet1, sheet2} from` is syntactic sugar that isn't actually needed for what the `@sheet` feature is trying to solve? It is something that could be added later?

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


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

Received on Thursday, 22 January 2026 11:05:31 UTC