# postcss-color

> PostCSS plugin to transform latest W3C CSS color module syntax to more compatible CSS

Latest version **1.0.1** (published 2014-09-16) · MIT license · 0 weekly downloads

## Install

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

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2014-09-16 |
| First published | 2014-08-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | MoOx |
| Maintainers | moox |
| Keywords | css, postcss, postcss-plugins, color, colour, rgb, hwb, rebeccapurple, color-function, function |

## Links

- npm: https://www.npmjs.com/package/postcss-color
- Repository: https://github.com/postcss/postcss-color
- Issues: https://github.com/postcss/postcss-color/issues
- npm.io page: https://npm.io/package/postcss-color

## Dependencies (4)

- [color](https://npm.io/package/color.md) ^0.7.1
- [balanced-match](https://npm.io/package/balanced-match.md) ^0.1.0
- [css-color-function](https://npm.io/package/css-color-function.md) ^1.1.1
- [reduce-function-call](https://npm.io/package/reduce-function-call.md) ^1.0.1

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

- 1.0.1 (latest) — 2014-09-16
- 1.0.0 — 2014-08-13

## README

# postcss-color [![Build Status](https://travis-ci.org/postcss/postcss-color.png)](https://travis-ci.org/postcss/postcss-color)

> [PostCSS](https://github.com/postcss/postcss) plugin to transform latest [W3C CSS color module](http://dev.w3.org/csswg/css-color/#modifying-colors) syntax to more compatible CSS.

This plugin can:

- transform [`color()`](http://dev.w3.org/csswg/css-color/#modifying-colors) to `rgb()` (or `rgba()`).
- transform [RGBA hexadecimal notations (`#RRGGBBAA` or `#RGBA`)](http://dev.w3.org/csswg/css-color/#hex-notation) to `rgba()`.
- transform [`hwb()`](http://dev.w3.org/csswg/css-color/#the-hwb-notation) to `rgb()` (or `rgba()`).
- transform [`rebeccapurple`](http://dev.w3.org/csswg/css-color/#valuedef-color-rebeccapurple) to `rgb()`.

## Installation

    $ npm install postcss-color

## Usage

```js
// dependencies
var fs = require("fs")
var postcss = require("postcss")
var color = require("postcss-color")

// css to be processed
var css = fs.readFileSync("input.css", "utf8")

// process css
var output = postcss()
  .use(color())
  .process(css)
  .css
```

Using this `input.css`:

```css
body {
  background:
    rgb(102, 51, 153)
    linear-gradient(
      color(rebeccapurple a(50%)),
      hwb(0, 20%, 40%),
      color(hwb(0, 20%, 40%, .5) a(+10%)),
      color(#9d9c a(90%))
    )
}

```

you will get:

```css
body {
  background:
    rgb(102, 51, 153)
    linear-gradient(
      rgba(102, 51, 153, 0.5),
      rgb(153, 51, 51),
      rgba(153, 51, 51, 0.55),
      rgba(153, 221, 153, 0.9)
    )
}
```

Checkout [tests](test) for more examples.

### Options

#### `color` (default: `true`)

Allow you to disable transformation of `color()`

#### `hexAlpha` (default: `true`)

Allow you to disable transformation of `#RRGGBBAA` or `#RGBA`

#### `hwb` (default: `true`)

Allow you to disable transformation of `hwb()`

#### `rebeccapurple` (default: `true`)

Allow you to disable transformation of `rebeccapurple`

---

## Contributing

Work on a branch, install dev-dependencies, respect coding style & run tests before submitting a bug fix or a feature.

    $ git clone https://github.com/postcss/postcss-color.git
    $ git checkout -b patch-1
    $ npm install
    $ npm test

## [Changelog](CHANGELOG.md)

## [License](LICENSE)

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