# @csstools/postcss-relative-color-syntax

> Use the relative color syntax in CSS

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

## Install

```sh
npm install @csstools/postcss-relative-color-syntax
pnpm add @csstools/postcss-relative-color-syntax
yarn add @csstools/postcss-relative-color-syntax
bun add @csstools/postcss-relative-color-syntax
```

## Health

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

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

Warnings: low downloads; no types.

## Facts

| | |
|---|---|
| Version | 4.0.12 |
| Published | 2026-09-13 |
| First published | 2023-05-19 |
| Weekly downloads | 0 |
| License | MIT-0 |
| TypeScript types | none |
| Module format | ESM |
| Node | >=20.19.0 |
| Dependencies | 5 |
| Unpacked size | 7.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1052 |
| Maintainers | jonathantneal, alaguna, romainmenke |
| Keywords | color, postcss-plugin, relative color syntax |

## Links

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

## Dependencies (5)

- [@csstools/utilities](https://npm.io/package/@csstools/utilities.md) ^3.0.0
- [@csstools/css-tokenizer](https://npm.io/package/@csstools/css-tokenizer.md) ^4.0.0
- [@csstools/css-color-parser](https://npm.io/package/@csstools/css-color-parser.md) ^4.2.3
- [@csstools/css-parser-algorithms](https://npm.io/package/@csstools/css-parser-algorithms.md) ^4.0.0
- [@csstools/postcss-progressive-custom-properties](https://npm.io/package/@csstools/postcss-progressive-custom-properties.md) ^5.1.3

## Alternatives

- [postcss-color-hex-alpha](https://npm.io/package/postcss-color-hex-alpha.md) — 6.4M weekly downloads
- [randomcolor](https://npm.io/package/randomcolor.md) — 348.0K weekly downloads
- [bows](https://npm.io/package/bows.md) — 1.3K weekly downloads
- [ep_prefer_color_scheme](https://npm.io/package/ep_prefer_color_scheme.md) — 260 weekly downloads
- [coc-yank](https://npm.io/package/coc-yank.md) — 61 weekly downloads

## Recent versions

- 4.0.12 (latest) — 2026-09-13
- 4.0.11 — 2026-09-06
- 4.0.10 — 2026-08-31
- 4.0.9 — 2026-08-25
- 4.0.8 — 2026-08-15
- 4.0.7 — 2026-07-22
- 4.0.6 — 2026-06-28
- 4.0.5 — 2026-06-14
- 4.0.4 — 2026-05-13
- 4.0.3 — 2026-04-12
- 4.0.2 — 2026-02-21
- 4.0.1 — 2026-01-25
- 4.0.0 — 2026-01-14
- 3.0.12 — 2025-09-21
- 3.0.11 — 2025-08-22
- … 34 more at https://npm.io/package/@csstools/postcss-relative-color-syntax/versions

## README

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

`npm install @csstools/postcss-relative-color-syntax --save-dev`

[PostCSS Relative Color Syntax] lets you use the relative color syntax in CSS color functions following [CSS Color Module 5].

```css
.example {
	background: oklab(from oklab(54.3% -22.5% -5%) calc(1.0 - l) calc(a * 0.8) b);
}

/* becomes */

.example {
	background: rgb(12, 100, 100);
}
```

> [!NOTE]
> We can not dynamically resolve `var()` arguments in relative color syntax, only static values will work.

## Usage

Add [PostCSS Relative Color Syntax] to your project:

```bash
npm install postcss @csstools/postcss-relative-color-syntax --save-dev
```

Use it as a [PostCSS] plugin:

```js
const postcss = require('postcss');
const postcssRelativeColorSyntax = require('@csstools/postcss-relative-color-syntax');

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



## Options

### preserve

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

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

```css
.example {
	background: oklab(from oklab(54.3% -22.5% -5%) calc(1.0 - l) calc(a * 0.8) b);
}

/* becomes */

.example {
	background: rgb(12, 100, 100);
	background: oklab(from oklab(54.3% -22.5% -5%) calc(1.0 - l) calc(a * 0.8) b);
}
```

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

[PostCSS]: https://github.com/postcss/postcss
[PostCSS Relative Color Syntax]: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-relative-color-syntax
[CSS Color Module 5]: https://www.w3.org/TR/css-color-5/#relative-colors

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