Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

postcss-modules-values

css-modules79.3mISC4.0.0TypeScript support: definitely-typed

PostCSS plugin for CSS Modules to pass arbitrary values between your module files

css, modules, postcss

readme

CSS Modules: Values

Pass arbitrary values between your module files

Usage

/* colors.css */
@value primary: #BF4040;
@value secondary: #1F4F7F;

.text-primary {
  color: primary;
}

.text-secondary {
  color: secondary;
}
/* breakpoints.css */
@value small: (max-width: 599px);
@value medium: (min-width: 600px) and (max-width: 959px);
@value large: (min-width: 960px);
/* my-component.css */
/* alias paths for other values or composition */
@value colors: "./colors.css";
/* import multiple from a single file */
@value primary, secondary from colors;
/* make local aliases to imported values */
@value small as bp-small, large as bp-large from "./breakpoints.css";
/* value as selector name */
@value selectorValue: secondary-color;

.selectorValue {
  color: secondary;
}

.header {
  composes: text-primary from colors;
  box-shadow: 0 0 10px secondary;
}

@media bp-small {
  .header {
    box-shadow: 0 0 4px secondary;
  }
}
@media bp-large {
  .header {
    box-shadow: 0 0 20px secondary;
  }
}

If you are using Sass along with this PostCSS plugin, do not use the colon : in your @value definitions. It will cause Sass to crash.

Note also you can import multiple values at once but can only define one value per line.

@value a: b, c: d; /* defines a as "b, c: d" */

License

ISC

With thanks

  • Mark Dalgleish
  • Tobias Koppers
  • Josh Johnston

Glen Maddern, 2015.

changelog

Change Log

All notable changes to this project will be documented in this file. This project adheres to Semantic Versioning.

4.0.0 - 2020-13-08

Fixes

  • compatibility with other plugins

4.0.0-rc.5 - 2020-11-08

Fixes

  • compatibility with other plugins

4.0.0-rc.4 - 2020-10-08

Fixes

  • perf
  • compatibility with empty custom properties
  • works with options.createImportedName

4.0.0-rc.3 - 2020-10-08

BREAKING CHANGE

  • minimum supported postcss version is ^8.1.0

Fixes

  • minimum supported Node.js version is ^10 || ^12 || >= 14
  • compatibility with PostCSS 8

4.0.0-rc.2 - 2020-09-22

Fixes

  • avoid using postcss directly to create decls and rules

4.0.0-rc.1 - 2020-09-22

BREAKING CHANGE

  • update icss-utils for PostCSS 8 compatibility

4.0.0-rc.0 - 2020-09-18

BREAKING CHANGE

  • minimum supported Node.js version is >= 10.13.0 || >= 12.13.0 || >= 14
  • minimum supported postcss version is ^8.0.3
  • postcss was moved to peerDependencies, you need to install postcss in your project before use the plugin