# postcss-color-hex-alpha

> Use 4 & 8 character hex color notation in CSS

Latest version **11.0.1** (published 2026-09-06) · MIT license · 6.4M weekly downloads

## Install

```sh
npm install postcss-color-hex-alpha
pnpm add postcss-color-hex-alpha
yarn add postcss-color-hex-alpha
bun add postcss-color-hex-alpha
```

## Health

**Score 80/100 (A)** — status: active.

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

Warnings: no types.

## Facts

| | |
|---|---|
| Version | 11.0.1 |
| Published | 2026-09-06 |
| First published | 2014-10-04 |
| Weekly downloads | 6.4M |
| License | MIT |
| TypeScript types | none |
| Module format | ESM |
| Node | >=20.19.0 |
| Dependencies | 2 |
| Unpacked size | 5.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1052 |
| Maintainers | jonathantneal, alaguna, romainmenke, moox, semigradsky |
| Keywords | 4-digit, 8-digit, alpha, color, css, csswg, hex, postcss, postcss-plugin, spec, specification, transparency, transparent, w3c |

## Links

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

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

- [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
- [colour-proximity](https://npm.io/package/colour-proximity.md) — 49 weekly downloads

## Recent versions

- 11.0.1 (latest) — 2026-09-06
- 11.0.0 — 2026-01-14
- 10.0.0 — 2024-08-03
- 9.0.4 — 2024-02-19
- 9.0.3 — 2023-12-15
- 9.0.2 — 2023-02-06
- 9.0.1 — 2023-01-28
- 9.0.0 — 2023-01-24
- 8.0.4 — 2022-06-10
- 8.0.3 — 2022-02-05
- 8.0.2 — 2022-01-02
- 8.0.1 — 2021-12-16
- 8.0.0 — 2021-09-22
- 7.0.0 — 2021-01-12
- 6.0.0 — 2020-04-25
- … 11 more at https://npm.io/package/postcss-color-hex-alpha/versions

## README

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

`npm install postcss-color-hex-alpha --save-dev`

[PostCSS Color Hex Alpha] lets you use 4 & 8 character hex color notation in
CSS, following the [CSS Color Module] specification.

```css
body {
	background: #9d9c;
}

/* becomes */

body {
	background: rgba(153,221,153,0.8);
}
```

## Usage

Add [PostCSS Color Hex Alpha] to your project:

```bash
npm install postcss postcss-color-hex-alpha --save-dev
```

Use it as a [PostCSS] plugin:

```js
const postcss = require('postcss');
const postcssColorHexAlpha = require('postcss-color-hex-alpha');

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



## Options

### preserve

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

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

```css
body {
	background: #9d9c;
}

/* becomes */

body {
	background: rgba(153,221,153,0.8);
	background: #9d9c;
}
```

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

[PostCSS]: https://github.com/postcss/postcss
[PostCSS Color Hex Alpha]: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-color-hex-alpha
[CSS Color Module]: https://www.w3.org/TR/css-color-4/#hex-notation

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