# @csstools/postcss-sign-functions

> Use sign and abs functions in CSS

Latest version **2.0.6** (published 2026-09-13) · MIT-0 license · 0 weekly downloads

## Install

```sh
npm install @csstools/postcss-sign-functions
pnpm add @csstools/postcss-sign-functions
yarn add @csstools/postcss-sign-functions
bun add @csstools/postcss-sign-functions
```

## Health

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

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

Warnings: low downloads; no types.

## Facts

| | |
|---|---|
| Version | 2.0.6 |
| Published | 2026-09-13 |
| First published | 2024-11-11 |
| Weekly downloads | 0 |
| License | MIT-0 |
| TypeScript types | none |
| Module format | ESM |
| Node | >=20.19.0 |
| Dependencies | 3 |
| Unpacked size | 7.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1052 |
| Maintainers | jonathantneal, alaguna, romainmenke |
| Keywords | abs, css, postcss-plugin, sign |

## Links

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

## Dependencies (3)

- [@csstools/css-calc](https://npm.io/package/@csstools/css-calc.md) ^3.4.0
- [@csstools/css-tokenizer](https://npm.io/package/@csstools/css-tokenizer.md) ^4.0.0
- [@csstools/css-parser-algorithms](https://npm.io/package/@csstools/css-parser-algorithms.md) ^4.0.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

- 2.0.6 (latest) — 2026-09-13
- 2.0.5 — 2026-09-06
- 2.0.4 — 2026-07-22
- 2.0.3 — 2026-05-13
- 2.0.2 — 2026-04-12
- 2.0.1 — 2026-02-21
- 2.0.0 — 2026-01-14
- 1.1.4 — 2025-05-27
- 1.1.3 — 2025-04-19
- 1.1.2 — 2025-02-23
- 1.1.1 — 2024-12-27
- 1.1.0 — 2024-11-17
- 1.0.0 — 2024-11-11

## README

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

`npm install @csstools/postcss-sign-functions --save-dev`

[PostCSS Sign Functions] lets you use the `sign` and `abs` functions, following the [CSS Values 4] specification.

```css
.sign {
	z-index: sign(-10px);
}

.sign {
	z-index: sign(0);
}

.sign {
	z-index: sign(10px);
}

.abs {
	z-index: abs(-10px);
}

.abs {
	z-index: abs(0);
}

.abs {
	z-index: abs(10px);
}

.abs {
	z-index: abs(10%);
}

/* becomes */

.sign {
	z-index: calc(-1);
}

.sign {
	z-index: calc(0);
}

.sign {
	z-index: calc(1);
}

.abs {
	z-index: calc(10px);
}

.abs {
	z-index: calc(0);
}

.abs {
	z-index: calc(10px);
}

.abs {
	z-index: max((10%), -1 * (10%));
}
```

> [!NOTE]
> The utility of static fallbacks for `sign` and `abs` is limited.
> The most interesting values are variables and dynamic values (e.g. those containing `%`).
> It is impossible to generate static fallbacks in a build process for values that are dynamic on the client.

## Usage

Add [PostCSS Sign Functions] to your project:

```bash
npm install postcss @csstools/postcss-sign-functions --save-dev
```

Use it as a [PostCSS] plugin:

```js
const postcss = require('postcss');
const postcssSignFunctions = require('@csstools/postcss-sign-functions');

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



## ⚠️ About custom properties

Given the dynamic nature of custom properties it's impossible to know what the variable value is, which means the plugin can't compute a final value for the stylesheet. 

Because of that, any usage that contains a `var` is skipped.

## Options

### preserve

The `preserve` option determines whether the original notation
is preserved. By default, it is not preserved.

```js
postcssSignFunctions({ preserve: true })
```

```css
.sign {
	z-index: sign(-10px);
}

.sign {
	z-index: sign(0);
}

.sign {
	z-index: sign(10px);
}

.abs {
	z-index: abs(-10px);
}

.abs {
	z-index: abs(0);
}

.abs {
	z-index: abs(10px);
}

.abs {
	z-index: abs(10%);
}

/* becomes */

.sign {
	z-index: calc(-1);
	z-index: sign(-10px);
}

.sign {
	z-index: calc(0);
	z-index: sign(0);
}

.sign {
	z-index: calc(1);
	z-index: sign(10px);
}

.abs {
	z-index: calc(10px);
	z-index: abs(-10px);
}

.abs {
	z-index: calc(0);
	z-index: abs(0);
}

.abs {
	z-index: calc(10px);
	z-index: abs(10px);
}

.abs {
	z-index: max((10%), -1 * (10%));
	z-index: abs(10%);
}
```

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

[PostCSS]: https://github.com/postcss/postcss
[PostCSS Sign Functions]: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-sign-functions
[CSS Values 4]: https://drafts.csswg.org/css-values-4/#sign-funcs

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