Use Less CSS across browser extension pages and UI components with a single pipeline that also supports module-scoped styles. Extension.js detects Less usage, configures the preprocessors in the Rspack build, and supports bothDocumentation Index
Fetch the complete documentation index at: https://extension.js.org/llms.txt
Use this file to discover all available pages before exploring further.
.less and .module.less files in browser extensions.
When Less is a good fit
- You are migrating an existing Less-based web codebase.
- You want variables and nesting with low migration cost.
- You need module-scoped styles while keeping Less conventions.
Template examples
new-less

Usage with an existing extension
Add Less 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 Less through your script entry:In a content_script file
Less modules in browser extensions
Scope class names locally with Less modules, just like CSS modules. This prevents global style conflicts by default, which matters in extensions because content scripts run inside a host page’s CSS scope.content-less-modules

Using Less modules in an existing extension
To enable Less modules, rename your.less files to include .module.less. This enables automatic local scoping of class names.
Example usage
After renaming your Less file, you can import it into your scripts:React/Preact example usage
To use Less modules in React or Preact, import your Less module and apply styles as you would in any component:Vue example usage
In Vue, prefer single-file component (SFC) styles withlang="less" and module:
Svelte example usage
In Svelte, import Less module mappings and apply classes:Behavior notes
- In extension page contexts,
.module.lessexports class maps as expected. - In content scripts, Extension.js emits styles as CSS assets and injects them as stylesheets into the page.
- If your project lacks Less tooling, Extension.js installs the optional dependencies and asks for a restart.
Next steps
- Learn more about CSS modules.
- Configure PostCSS in your extension.

