Repository navigation
Description
Description
Allow importing CSS files from within JavaScript modules using import assertions and adoptedStyleSheets:
import sheet from './styles.css' with { type: 'css' };
document.adoptedStyleSheets = [sheet];
shadowRoot.adoptedStyleSheets = [sheet];The cool thing is that this allows you to manipulate stylesheets with JavaScript before applying them. For example, @davatron5000 has a neat example of how to emulate CSS modules (the confusingly-similar non-standard name for scoping CSS by hashing class names) using CSS Module Scripts: https://daverupert.com/2021/08/css-modules-in-css-modules/
Specification
web-feature
Test Links
https://wpt.fyi/results/html/semantics/scripting-1/the-script-element/css-module
https://github.com/web-platform-tests/wpt/tree/master/html/semantics/scripting-1/the-script-element/css-module
Additional Signals
https://bugzilla.mozilla.org/show_bug.cgi?id=1720570
https://bugs.webkit.org/show_bug.cgi?id=227967
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
github-actions commentedon Sep 9, 2025
This comment was automatically generated based on the information you provided. Please don't edit it.
Below is additional information about the web feature (from the web-features project) which is referenced in your proposal.
If this doesn't accurately correspond to your proposal, please update your initial comment to include
web-features: <feature-id>.To find feature IDs, use the web-features explorer.
Feature CSS import attributes
import … with { type: "css" }statements load CSS modules as constructable stylesheets. Also known as CSS module scripts.o-t-w commentedon Oct 1, 2025
This feature is now available in Firefox Nightly:
wpt-interop commentedon Feb 12, 2026
Thank you for proposing CSS Module Scripts for Interop 2026.
We want to let you know it was not selected to be part of Interop this year.
On behalf of the entire Interop team, thank you for submitting it for consideration. We got many more proposals than we could include in this year's project, necessitating some difficult choices. Please note this should not be taken as a comment on the technology as a whole, or our willingness to consider it for Interop in the future. We appreciate the work you put into your proposal, and would welcome your participation in future rounds of Interop.
Posted on behalf of the Interop team.
klebba commentedon Mar 11, 2026
(UGHHHHH. This is so disappointing. IS THERE NO HOPE FOR THE WEB!!??)
The browser groundhog has seen its ShadowDOM again and doomed the web to another year of CSS-in-JS.
If you found this thread and still fantasize about using encapsulated native stylesheets, consider politely nudging this issue with your interest: https://bugs.webkit.org/show_bug.cgi?id=227967
Another idea: maybe @LeaVerou has the star power necessary to get this one over the finish line sooner?! If you're reading this, please help! I don't want to transpile my CSS any more!
LeaVerou commentedon Mar 12, 2026
This may be a productive avenue: https://bsky.app/profile/lukewarlow.dev/post/3mguqlqozck23
klebba commentedon Mar 12, 2026
Thank you!
For reference, here are all Interop request/rejection threads for CSS Module Scripts:
It would be great to see the Interop team reevaluate inclusion using cumulative and lasting community interest.