# @csstools/postcss-alpha-function

> Use the alpha() function in CSS

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

## Install

```sh
npm install @csstools/postcss-alpha-function
pnpm add @csstools/postcss-alpha-function
yarn add @csstools/postcss-alpha-function
bun add @csstools/postcss-alpha-function
```

## 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.13 |
| Published | 2026-09-13 |
| First published | 2025-08-22 |
| Weekly downloads | 0 |
| License | MIT-0 |
| TypeScript types | none |
| Module format | ESM |
| Node | >=20.19.0 |
| Dependencies | 5 |
| Unpacked size | 9.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1053 |
| Maintainers | jonathantneal, alaguna, romainmenke |
| Keywords | alpha, color, css, design, postcss, postcss-plugin |

## Links

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

## 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

- [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.13 (latest) — 2026-09-13
- 2.0.12 — 2026-09-06
- 2.0.11 — 2026-08-31
- 2.0.10 — 2026-08-25
- 2.0.9 — 2026-08-15
- 2.0.8 — 2026-07-22
- 2.0.7 — 2026-06-28
- 2.0.6 — 2026-06-14
- 2.0.5 — 2026-05-13
- 2.0.4 — 2026-04-12
- 2.0.3 — 2026-02-21
- 2.0.2 — 2026-01-25
- 2.0.1 — 2026-01-15
- 2.0.0 — 2026-01-14
- 1.0.1 — 2025-09-21
- … 1 more at https://npm.io/package/@csstools/postcss-alpha-function/versions

## README

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

`npm install @csstools/postcss-alpha-function --save-dev`

[PostCSS Alpha Function] lets you use the `alpha` function in
CSS, following the [CSS Color] specification.

```css
.color {
	color: alpha(from #dddd / calc(alpha / 2));
}

:root {
	--a-color: alpha(from rgb(2 1 0 / var(--a)) / calc(alpha / 2));
}

/* becomes */

.color {
	color: rgb(from #dddd r g b / calc(alpha / 2));
}

:root {
	--a-color: rgb(from rgb(2 1 0 / var(--a)) r g b / calc(alpha / 2));
}
```

## Usage

Add [PostCSS Alpha Function] to your project:

```bash
npm install postcss @csstools/postcss-alpha-function --save-dev
```

Use it as a [PostCSS] plugin:

```js
const postcss = require('postcss');
const postcssAlphaFunction = require('@csstools/postcss-alpha-function');

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



## Options

### preserve

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

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

```css
.color {
	color: alpha(from #dddd / calc(alpha / 2));
}

:root {
	--a-color: alpha(from rgb(2 1 0 / var(--a)) / calc(alpha / 2));
}

/* becomes */

.color {
	color: rgb(from #dddd r g b / calc(alpha / 2));
	color: alpha(from #dddd / calc(alpha / 2));
}

:root {
	--a-color: rgb(from rgb(2 1 0 / var(--a)) r g b / calc(alpha / 2));
}

@supports (color: alpha(from red / 1)) and (color: rgb(0 0 0 / 0)) {
:root {
	--a-color: alpha(from rgb(2 1 0 / var(--a)) / calc(alpha / 2));
}
}
```

### enableProgressiveCustomProperties

The `enableProgressiveCustomProperties` option determines whether the original notation
is wrapped with `@supports` when used in Custom Properties. By default, it is enabled.

> [!NOTE]
> We only recommend disabling this when you set `preserve` to `false` or if you bring your own fix for Custom Properties.  
> See what the plugin does in its [README](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-progressive-custom-properties#readme).

```js
postcssAlphaFunction({ enableProgressiveCustomProperties: false })
```

```css
.color {
	color: alpha(from #dddd / calc(alpha / 2));
}

:root {
	--a-color: alpha(from rgb(2 1 0 / var(--a)) / calc(alpha / 2));
}

/* becomes */

.color {
	color: rgb(from #dddd r g b / calc(alpha / 2));
	color: alpha(from #dddd / calc(alpha / 2));
}

:root {
	--a-color: rgb(from rgb(2 1 0 / var(--a)) r g b / calc(alpha / 2));
	--a-color: alpha(from rgb(2 1 0 / var(--a)) / calc(alpha / 2));
}
```

_Custom properties do not fallback to the previous declaration_

## Copyright : color conversions

This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/tree/main/css-color-4. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).

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

[PostCSS]: https://github.com/postcss/postcss
[PostCSS Alpha Function]: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-alpha-function
[CSS Color]: https://drafts.csswg.org/css-color-5/#relative-alpha

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