JSPM

@csstools/postcss-nested-calc

4.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 3718066
  • Score
    100M100P100Q235382F
  • License MIT-0

Use nested calc() expressions in CSS

Package Exports

  • @csstools/postcss-nested-calc

Readme

PostCSS Nested Calc PostCSS Logo

npm install @csstools/postcss-nested-calc --save-dev

PostCSS Nested Calc lets you use nested calc() expressions following the CSS Values and Units 4 specification.

.example {
    order: calc(1 + calc(2 * 2));
}

/* becomes */

.example {
    order: calc(1 + (2 * 2));
    order: calc(1 + calc(2 * 2));
}

Usage

Add PostCSS Nested Calc to your project:

npm install postcss @csstools/postcss-nested-calc --save-dev

Use it as a PostCSS plugin:

const postcss = require('postcss');
const postcssNestedCalc = require('@csstools/postcss-nested-calc');

postcss([
    postcssNestedCalc(/* pluginOptions */)
]).process(YOUR_CSS /*, processOptions */);

Options

preserve

The preserve option determines whether the original notation is preserved. By default the original values are preserved.

postcssNestedCalc({ preserve: false })
.example {
    order: calc(1 + calc(2 * 2));
}

/* becomes */

.example {
    order: calc(1 + (2 * 2));
}