Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

postcss-modules

Package Overview
Dependencies
Maintainers
1
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postcss-modules

PostCSS plugin to use CSS Modules everywhere

  • 5.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
659K
decreased by-52.59%
Maintainers
1
Weekly downloads
 
Created

What is postcss-modules?

The postcss-modules package is a PostCSS plugin that enables CSS Modules, a technique for locally scoping CSS by automatically creating a unique classname of the format [filename]__[local classname]__[hash]. This helps in avoiding global scope pollution in CSS and makes component-based development easier and more maintainable.

What are postcss-modules's main functionalities?

Local Scope for CSS Classes

This feature automatically scopes class names locally rather than globally. This is done by appending a unique hash to each class name, which makes them unique across the project. This prevents styles from leaking into other parts of the application unintentionally.

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

/* Output CSS */
.fileName__className__hash {
  color: red;
}

Composition of Styles

This feature allows CSS classes to compose from other classes, potentially from different files. This promotes reusability of CSS styles and helps in maintaining a cleaner and more organized stylesheet architecture.

/* Input CSS */
.className {
  composes: anotherClass from './anotherStyle.css';
  color: red;
}

/* Output CSS */
.fileName__className__hash {
  color: red;
}
.fileName__anotherClass__hash {
  /* styles from anotherClass */
}

Other packages similar to postcss-modules

Keywords

FAQs

Package last updated on 15 Aug 2022

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc