@zslabs/atomic-css-modules weekly downloads statistics
By zslabs · npm · Webpack plugins
Extract repeated CSS Modules declarations into shared atomic classes
@zslabs/atomic-css-modules has 400 recorded weekly downloads on npm, ranking #1698 of 2,865 tracked listings.
About @zslabs/atomic-css-modules
@zslabs/atomic-css-modules
Extracts repeated CSS Modules declarations into shared atomic classes via composes.
Requirements
- Node.js
>=20.17or>=22.5(usespath.matchesGlob) - CSS Modules source (
.module.css) - Vite
^8when using the Vite plugin (viteis an optional peer) - webpack
^5withcss-loader^7, or Rspack^2withcss-loaderor native CSS, when using the webpack plugin (all optional peers) - PostCSS
^8when using the PostCSS plugin (optional peer). This is the Next.js integration, for Turbopack and fornext dev --webpack
The core processCssModules API has no bundler dependency.
Install
npm install @zslabs/atomic-css-modules
Vite
import { defineConfig } from 'vite'
import { atomicCssModules } from '@zslabs/atomic-css-modules/vite'
export default defineConfig({
plugins: [
atomicCssModules({
include: ['src/**/*.module.css'],
}),
],
})
webpack / Rspack
Add the plugin alongside your existing CSS setup. It injects its own loaders ahead of css-loader, so no extra rules are needed.
import MiniCssExtractPlugin from 'mini-css-extract-plugin'
import { AtomicCssModulesWebpackPlugin } from '@zslabs/atomic-css-modules/webpack'
export default {
module: {
rules: [
{
test: /\.css$/,
use: [MiniCssExtractPlugin.loader, 'css-loader'],
},
],
},
plugins: [
new MiniCssExtractPlugin(),
new AtomicCssModulesWebpackPlugin({
include: ['src/**/*.module.css'],
}),
],
}
On Rspack, use rspack.CssExtractRspackPlugin with the same rule, or native CSS with the standard { test: /\.css$/, type: 'css/auto' } rule and experiments.css: true.
Keep css-loader's default modules.auto (or any setting that only scopes *.module.css). The shared registry is a plain .css file shipped with the package and must stay global.
Next.js
Turbopack does not run webpack plugins, and it will not run a loader that rewrites stylesheets. Next.js does run postcss.config.js before Lightning CSS scopes .module.css, on Turbopack and on webpack. The PostCSS plugin is the integration.
// postcss.config.js
import { atomicCssModulesPostcss } from '@zslabs/atomic-css-modules/postcss'
export default {
plugins: [atomicCssModulesPostcss()],
}
Next.js loads postcss.config.js in Node. It bundles postcss.config.mjs, and that bundle cannot load the native lightningcss addon this plugin uses, so the config file has to be postcss.config.js and Node has to treat it as ESM ("type": "module", or an app that already is). A CommonJS config that only names the package does not load it.
Put @atomic-css-modules; in the global CSS imported by the root layout. The plugin replaces that at-rule with the shared atom rules. App Router only allows global CSS from that layout, so the registry is not injected into components.
@atomic-css-modules;
body {
margin: 0;
}
next dev uses readable atom names. next build uses short hashes. Globs are relative to the directory where the PostCSS config is loaded (root overrides that).
Options
| Option | Default | Notes |
|---|---|---|
include | **/*.module.css | Globs relative to the Vite root, webpack context, or PostCSS cwd |
exclude | **/node_modules/** | |
debugNames | true in dev, false in build | Readable atoms (color-red-a1b2c3) vs short hashes |
report | "summary" | "verbose" lists each skipped selector |
preprocess | — | (code, filePath) => code before scan/atomize |
"Dev" means vite serve, webpack/Rspack in development mode, or next dev. Production watch keeps the short hashes.
How it works
Matching declarations share one registry class. Single local classes are eligible, including simple pseudos and nested at-rules.
.card {
color: red;
&:hover {
color: blue;
}
@media (min-width: 600px) {
padding: 16px;
}
}
becomes:
/* module */
.card {
composes: bn89ziv jtnf3j g1h5a7 from global;
}
/* registry */
.bn89ziv {
color: red;
}
.jtnf3j:hover {
color: #00f;
}
@media (width >= 600px) {
.g1h5a7 {
padding: 16px;
}
}
Selector eligibility, shorthand/longhand rules, and non-goals: GUIDE.md.
Skipping
Add /* atomic: skip */ before a selector, or as the first comment in a rule block, to leave that rule alone. Use it when a declaration would atomize but sharing it would break cascade or you need the styles to stay on the local class.
The first build logs atom count, skip reasons, and source vs registry bytes.
Caveats
- Only selectors that CSS Modules can
composesare atomized (see the guide). - Shorthand + longhand in the same rule skip those properties for that rule.
- Stick to CSS Modules local classes. Do not stack atomized classes, or another utility system on the same node, to override the same property. Prefer one class, or
/* atomic: skip */when sharing would be wrong. - On small sheets, gzip/brotli often erase the atomic class win (many one-declaration rules compress worse than fewer larger ones). The payoff shows up when UI grows against a shared token surface: Modules CSS scales with components, the atom set scales with the design system.
- This is 0.x: the supported surface below is stable within a minor when practical, but breaking changes may land before 1.0.
Public API
Supported…
Description from the npm listing.
- atomic-css
- css-modules
- nextjs
- postcss
- rspack
- rspack-plugin
- vite
- vite-plugin
- webpack
- webpack-plugin
README badge
Show your rank in a README or on your website. The badge updates automatically.
Charts
Images: 30d · 1y · all time · 1600×900 dark
Adoption over time
7/30/90-day growth
Ranking history
Listing placement
Listing placement
Filled points are observed values; hollow points come from Internet Archive snapshots of the listing page. Dashed segments span periods with no observations — values between points are not interpolated.
Each band is one page of 20. Weekly downloads on a linear scale. Placement is projected from weekly downloads, so it can differ from the marketplace's own sort order. Hover a dot to see the listing.
Recent observations
Full history (1)Similar npm Webpack plugins plugins
All 20 @zslabs/atomic-css-modules alternativesData source
Weekly downloads (trailing 7 complete days) come from the official npm downloads API. Downloads include CI and mirrors and are not equivalent to installs or users. npm publishes no ratings.
Listing: https://www.npmjs.com/package/@zslabs/atomic-css-modules. First seen Nov 6, 2026; last successful collection Nov 6, 2026. See the methodology.