# @csstools/postcss-nested-calc

> Use nested calc() expressions in CSS

Latest version **5.0.1** (published 2026-09-06) · MIT-0 license · 0 weekly downloads

## Install

```sh
npm install @csstools/postcss-nested-calc
pnpm add @csstools/postcss-nested-calc
yarn add @csstools/postcss-nested-calc
bun add @csstools/postcss-nested-calc
```

## Health

**Score 60/100 (C)** — status: active.

Positive: esm support; no vulnerabilities; recently updated; high maintenance score.

Warnings: low downloads; no types.

## Facts

| | |
|---|---|
| Version | 5.0.1 |
| Published | 2026-09-06 |
| First published | 2022-08-15 |
| Weekly downloads | 0 |
| License | MIT-0 |
| TypeScript types | none |
| Module format | ESM |
| Node | >=20.19.0 |
| Dependencies | 2 |
| Unpacked size | 5.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1052 |
| Maintainers | jonathantneal, alaguna, romainmenke |
| Keywords | calc, css, math, nested, postcss-plugin |

## Links

- npm: https://www.npmjs.com/package/@csstools/postcss-nested-calc
- Repository: https://github.com/csstools/postcss-plugins
- Homepage: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-nested-calc#readme
- Issues: https://github.com/csstools/postcss-plugins/issues
- Funding: https://github.com/sponsors/csstools
- npm.io page: https://npm.io/package/@csstools/postcss-nested-calc

## Dependencies (2)

- [@csstools/utilities](https://npm.io/package/@csstools/utilities.md) ^3.0.0
- [postcss-value-parser](https://npm.io/package/postcss-value-parser.md) ^4.2.0

## Alternatives

- [style-dictionary](https://npm.io/package/style-dictionary.md) — 2.0M weekly downloads
- [postcss-merge-idents](https://npm.io/package/postcss-merge-idents.md) — 1.7M weekly downloads
- [@fontsource/noto-sans](https://npm.io/package/@fontsource/noto-sans.md) — 93.0K weekly downloads
- [uglifycss](https://npm.io/package/uglifycss.md) — 71.6K weekly downloads
- [mat4-interpolate](https://npm.io/package/mat4-interpolate.md) — 23.3K weekly downloads

## Recent versions

- 5.0.1 (latest) — 2026-09-06
- 5.0.0 — 2026-01-14
- 4.0.0 — 2024-08-03
- 3.0.2 — 2024-02-19
- 3.0.1 — 2023-12-15
- 3.0.0 — 2023-07-03
- 2.0.2 — 2023-02-09
- 2.0.1 — 2023-01-28
- 2.0.0 — 2023-01-24
- 1.0.0 — 2022-08-15

## README

# PostCSS Nested Calc [<img src="https://postcss.github.io/postcss/logo.svg" alt="PostCSS Logo" width="90" height="90" align="right">][PostCSS]

`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].

```css
.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:

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

Use it as a [PostCSS] plugin:

```js
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.

```js
postcssNestedCalc({ preserve: false })
```

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

/* becomes */

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

[cli-url]: https://github.com/csstools/postcss-plugins/actions/workflows/test.yml?query=workflow/test
[css-url]: https://cssdb.org/#nested-calc
[discord]: https://discord.gg/bUadyRwkJS
[npm-url]: https://www.npmjs.com/package/@csstools/postcss-nested-calc

[PostCSS]: https://github.com/postcss/postcss
[PostCSS Nested Calc]: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-nested-calc
[CSS Values and Units 4 specification]: https://www.w3.org/TR/css-values/#calc-func

---
_Source: https://npm.io/package/@csstools/postcss-nested-calc · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
