styles.module.css). It routes them through the Rspack CSS pipeline. Class names stay locally scoped to the component that imported them.
When CSS modules are a good fit
- You need local class scoping without adopting a full CSS-in-JS stack.
- You share components across popup/options/new-tab surfaces.
- You want predictable style ownership in larger extension codebases.
Template examples
content-css-modules

Usage with an existing extension
To use CSS modules, name files with a module suffix:*.module.css*.module.scss*.module.sass*.module.less
Usage example
After renaming your stylesheet, import and use it in your component:How it works
Extension.js enables Rspack CSS support and handles module imports through the CSS module pipeline:- Default import style maps (
import styles from "./x.module.css") - Rspack generates scoped class names through its CSS module pipeline
- Module class exports work directly in JS/TS/TSX files
Content script note
Content scripts get the same treatment as extension pages. Rspack generates scoped class names, exports them to your JavaScript, and Extension.js registers the emitted stylesheet in the manifestcontent_scripts[].css entry, and in web_accessible_resources so it can also
be injected into a shadow root. Import the class names you need and apply them:
content-css-modules template above for a working example.
React/Preact example usage
For React or Preact, you can import and use the CSS module in the component like this:Vue example usage
In Vue, you can use module classes from single-file component (SFC) styles:Svelte example usage
In Svelte, import module mappings and apply class names:Best practices
- Keep module styles close to components (
Component.module.css) for easier ownership. - Use
:global(...)sparingly and only for intentional global overrides. - Prefer module styles for extension pages and framework components where class mapping is explicit.
Next steps
- Learn more about Sass and Sass modules.
- Learn more about Less and Less modules.

