Socket
Socket
Sign inDemoInstall

postcss-modules-local-by-default

Package Overview
Dependencies
8
Maintainers
3
Versions
37
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    postcss-modules-local-by-default

A CSS Modules transform to make local scope the default


Version published
Weekly downloads
18M
increased by4.25%
Maintainers
3
Install size
2.28 MB
Created
Weekly downloads
 

Package description

What is postcss-modules-local-by-default?

The postcss-modules-local-by-default npm package is a PostCSS plugin that modifies CSS class names to be locally scoped by default. This is part of CSS Modules, which helps avoid class name collisions and ensures styles are encapsulated to specific components only. It rewrites all class names in CSS files to be scoped locally unless explicitly specified otherwise.

What are postcss-modules-local-by-default's main functionalities?

Local Scoping of Class Names

Automatically transforms global CSS class names into locally scoped names. This prevents class name collisions across different components or sections of a web application.

/* Input CSS */
.className {
  color: red;
}

/* Output CSS after processing with postcss-modules-local-by-default */
._className_xkpkl_1 {
  color: red;
}

Selective Global Scoping

Allows developers to selectively keep some class names global. This is useful for overriding styles or for styles that are meant to be consistent across various components.

/* Input CSS */
:global(.globalClassName) {
  color: blue;
}

/* Output CSS remains unchanged */
.globalClassName {
  color: blue;
}

Other packages similar to postcss-modules-local-by-default

Changelog

Source

3.0.3 - 2020-07-25

Fixed

  • treat :import and :export statements as pure

Readme

Source

Build Status codecov npm

CSS Modules: Local by Default

Transformation examples:

.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) { ... }

Building

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

Development

$ npm run autotest

License

MIT

With thanks


Mark Dalgleish, 2015.

Keywords

FAQs

Last updated on 25 Jul 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc