Gathering detailed insights and metrics for postcss-calc
Gathering detailed insights and metrics for postcss-calc
Gathering detailed insights and metrics for postcss-calc
Gathering detailed insights and metrics for postcss-calc
@csstools/postcss-nested-calc
Use nested calc() expressions in CSS
@types/postcss-calc
Stub TypeScript definitions entry for postcss-calc, which provides its own types definitions
postcss-calc-ast-parser
Parses calc of css and converts it to AST.
@vusion/postcss-calc
PostCSS plugin to reduce calc()
npm install postcss-calc
Typescript
Module System
Min. Node Version
Node Version
NPM Version
98.7
Supply Chain
100
Quality
84.9
Maintenance
100
Vulnerability
100
License
JavaScript (83.13%)
Yacc (16.87%)
Total Downloads
3,155,794,994
Last Day
615,029
Last Week
11,769,737
Last Month
51,303,711
Last Year
574,415,753
MIT License
217 Stars
208 Commits
34 Forks
15 Watchers
6 Branches
31 Contributors
Updated on May 10, 2025
Minified
Minified + Gzipped
Latest Version
10.1.1
Package Id
postcss-calc@10.1.1
Unpacked Size
159.31 kB
Size
39.46 kB
File Count
15
NPM Version
11.1.0
Node Version
22.11.0
Published on
Jan 31, 2025
Cumulative downloads
Total Downloads
Last Day
-8.5%
615,029
Compared to previous day
Last Week
-9.6%
11,769,737
Compared to previous week
Last Month
2%
51,303,711
Compared to previous month
Last Year
3.9%
574,415,753
Compared to previous year
2
1
PostCSS Calc lets you reduce calc()
references whenever it's possible.
When multiple units are mixed together in the same expression, the calc()
statement is left as is, to fallback to the W3C calc() implementation.
1npm install postcss-calc
1// dependencies 2var fs = require("fs") 3var postcss = require("postcss") 4var calc = require("postcss-calc") 5 6// css to be processed 7var css = fs.readFileSync("input.css", "utf8") 8 9// process css 10var output = postcss() 11 .use(calc()) 12 .process(css) 13 .css
Using this input.css
:
1h1 { 2 font-size: calc(16px * 2); 3 height: calc(100px - 2em); 4 width: calc(2*var(--base-width)); 5 margin-bottom: calc(16px * 1.5); 6}
you will get:
1h1 { 2 font-size: 32px; 3 height: calc(100px - 2em); 4 width: calc(2*var(--base-width)); 5 margin-bottom: 24px 6}
Checkout tests for more examples.
precision
(default: 5
)Allow you to define the precision for decimal numbers.
1var out = postcss() 2 .use(calc({precision: 10})) 3 .process(css) 4 .css
preserve
(default: false
)Allow you to preserve calc() usage in output so browsers will handle decimal precision themselves.
1var out = postcss() 2 .use(calc({preserve: true})) 3 .process(css) 4 .css
warnWhenCannotResolve
(default: false
)Adds warnings when calc() are not reduced to a single value.
1var out = postcss() 2 .use(calc({warnWhenCannotResolve: true})) 3 .process(css) 4 .css
mediaQueries
(default: false
)Allows calc() usage as part of media query declarations.
1var out = postcss() 2 .use(calc({mediaQueries: true})) 3 .process(css) 4 .css
selectors
(default: false
)Allows calc() usage as part of selectors.
1var out = postcss() 2 .use(calc({selectors: true})) 3 .process(css) 4 .css
Example:
1div[data-size="calc(3*3)"] { 2 width: 100px; 3}
To replace the value of CSS custom properties at build time, try PostCSS Custom Properties.
Work on a branch, install dev-dependencies, respect coding style & run tests before submitting a bug fix or a feature.
1git clone git@github.com:postcss/postcss-calc.git 2git checkout -b patch-1 3npm install 4npm test
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
GitHub workflow tokens follow principle of least privilege
Details
Reason
license file detected
Details
Reason
4 existing vulnerabilities detected
Details
Reason
2 commit(s) and 2 issue activity found in the last 90 days -- score normalized to 3
Reason
Found 3/24 approved changesets -- score normalized to 1
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-06-23
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More