Scope styles by default and avoid naming collisions across extension pages, options UIs, and popups.
Extension.js supports CSS Modules with zero configuration for module-style filenames and uses the Rspack CSS pipeline under the hood.
content-css-modules
Add locally scoped styles to content-script UI with minimal setup.
Repository: extension-js/examples/content-css-modules
To use CSS Modules, name files with a module suffix:
*.module.css*.module.scss*.module.sass*.module.lessUse the related language pages for Sass and Less setup requirements.
After renaming your stylesheet, import and use it in your component:
Extension.js enables Rspack CSS support and handles module imports through the CSS module pipeline:
import styles from "./x.module.css")In extension page contexts (for example popup/options/new tab), module imports behave as expected with hashed/localized class mapping.
Content script styles use an asset-based CSS flow. In that context, CSS is emitted and injected as stylesheet content rather than consumed as CSS Module JS exports.
Use component-level local class naming in content scripts, and avoid assuming module export maps there unless your setup explicitly verifies that path.
For React or Preact, you can import and use the CSS Module in the component like this:
In Vue, you can use module classes from SFC styles:
In Svelte, import module mappings and apply class names:
Component.module.css) for easier ownership.:global(...) sparingly and only for intentional global overrides.