postcss-modules-local-by-default (4.2.0)

Published 2026-02-24 14:03:07 +00:00 by atheaadmin

Installation

registry=
npm install postcss-modules-local-by-default@4.2.0
"postcss-modules-local-by-default": "4.2.0"

About this package

Build Status codecov npm

CSS Modules: Local by Default

Transformation examples:

Selectors (mode local, by default)::

.foo { ... } /* => */ :local(.foo) { ... }

.foo .bar { ... } /* => */ :local(.foo) :local(.bar) { ... }

/* Shorthand global selector */

:global .foo .bar { ... } /* => */ .foo .bar { ... }

.foo :global .bar { ... } /* => */ :local(.foo) .bar { ... }

/* Targeted global selector */

:global(.foo) .bar { ... } /* => */ .foo :local(.bar) { ... }

.foo:global(.bar) { ... } /* => */ :local(.foo).bar { ... }

.foo :global(.bar) .baz { ... } /* => */ :local(.foo) .bar :local(.baz) { ... }

.foo:global(.bar) .baz { ... } /* => */ :local(.foo).bar :local(.baz) { ... }

Declarations (mode local, by default):

.foo {
  animation-name: fadeInOut, global(moveLeft300px), local(bounce);
}

.bar {
  animation: rotate 1s, global(spin) 3s, local(fly) 6s;
}

/* => */ 

:local(.foo) {
  animation-name: :local(fadeInOut), moveLeft300px, :local(bounce);
}

:local(.bar) {
  animation: :local(rotate) 1s, spin 3s, :local(fly) 6s;
}

Pure Mode

In pure mode, all selectors must contain at least one local class or id selector

To ignore this rule for a specific selector, add the a /* cssmodules-pure-ignore */ comment in front of the selector:

/* cssmodules-pure-ignore */
:global(#modal-backdrop) {
  ...;
}

or by adding a /* cssmodules-pure-no-check */ comment at the top of a file to disable this check for the whole file:

/* cssmodules-pure-no-check */

:global(#modal-backdrop) {
  ...;
}

:global(#my-id) {
  ...;
}

Building

$ npm install
$ npm test
  • Build: Build Status
  • Lines: coveralls
  • Statements: codecov

Development

$ yarn test:watch

License

MIT

With thanks


Mark Dalgleish, 2015.

Dependencies

Dependencies

ID Version
icss-utils ^5.0.0
postcss-selector-parser ^7.0.0
postcss-value-parser ^4.1.0

Development Dependencies

ID Version
coveralls ^3.1.0
eslint ^7.10.0
eslint-config-prettier ^6.12.0
husky ^4.3.0
jest ^26.5.2
lint-staged ^10.4.0
postcss ^8.1.0
prettier ^2.1.2

Peer Dependencies

ID Version
postcss ^8.1.0

Keywords

css-modules postcss css postcss-plugin
Details
npm
2026-02-24 14:03:07 +00:00
0
Mark Dalgleish
MIT
latest
7.2 KiB
Assets (1)
Versions (1) View all
4.2.0 2026-02-24