Skip to main content
Use Sass to scale browser extension styling with variables, nesting, and SCSS modules while keeping a single build workflow. Extension.js supports .scss and .sass, plus SCSS module variants (.module.scss, .module.sass) through the Rspack-based style pipeline.

When Sass is a good fit

  • Your design system already relies on Sass variables and mixins.
  • You need modular styles for component-driven extension UIs.
  • You want parity with existing Sass workflows in web applications.

Template examples

new-sass

new-sass template screenshot Start a new-tab extension with Sass support already configured.
Repository: extension-js/examples/new-sass

Usage with an existing extension

Add Sass to an existing extension with the steps below.

Installation

Install the required dependencies:

Example usage in an HTML file

In extension pages (popup/options/new tab), import Sass from your entry script:

Sass modules

Scope styles locally with Sass modules, just like CSS modules. Use .module.scss or .module.sass to activate scoping and prevent naming conflicts in your stylesheets.

content-sass-modules

content-sass-modules template screenshot Use Sass modules in content scripts when you need scoped styling for injected UI.
Repository: extension-js/examples/content-sass-modules

Using Sass modules in an existing extension

To enable Sass modules, rename your Sass file to include .module.scss or .module.sass. This automatically scopes the styles to your component.

Example usage

After renaming your Sass file, import it into your script:
In the Sass file:

React/Preact example usage

Import the Sass module into your React or Preact component, and use the scoped class names:

Vue example usage

In Vue SFCs, prefer module styles with lang="scss":

Svelte example usage

In Svelte, import Sass module mappings and apply classes:

Behavior notes

  • In extension pages, .module.scss and .module.sass export class maps for JS/TS imports.
  • In content scripts, Extension.js emits Sass as CSS assets without JavaScript class-name mappings.
  • If your project lacks Sass tooling, Extension.js installs the optional dependencies and asks for a restart.

Next steps

Video walkthrough