# postcss-opacity-percentage

> PostCSS plugin to transform percentage-based opacity values to more compatible floating-point values.

Latest version **3.0.0** (published 2024-09-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install postcss-opacity-percentage
pnpm add postcss-opacity-percentage
yarn add postcss-opacity-percentage
bun add postcss-opacity-percentage
```

## Health

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

Positive: no vulnerabilities; high maintenance score.

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

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 3.0.0 |
| Published | 2024-09-03 |
| First published | 2021-11-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=18 |
| Dependencies | 0 |
| Unpacked size | 5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 10 |
| Author | Marc Görtz |
| Maintainers | dreamseer |
| Keywords | postcss, css, postcss-plugin, opacity |

## Links

- npm: https://www.npmjs.com/package/postcss-opacity-percentage
- Repository: https://github.com/mrcgrtz/postcss-opacity-percentage
- Homepage: https://github.com/mrcgrtz/postcss-opacity-percentage#readme
- Issues: https://github.com/mrcgrtz/postcss-opacity-percentage/issues
- Funding: https://ko-fi.com/mrcgrtz
- npm.io page: https://npm.io/package/postcss-opacity-percentage

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

- 3.0.0 (latest) — 2024-09-03
- 2.0.0 — 2023-01-31
- 1.1.3 — 2022-12-16
- 1.1.2 — 2022-01-31
- 1.1.1 — 2022-01-26
- 1.1.0 — 2021-12-29
- 1.0.0 — 2021-11-08
- 0.0.3 — 2021-11-08
- 0.0.2 — 2021-11-08
- 0.0.1 — 2021-11-08

## README

# PostCSS Opacity Percentage

[![Test](https://github.com/mrcgrtz/postcss-opacity-percentage/actions/workflows/test.yml/badge.svg)](https://github.com/mrcgrtz/postcss-opacity-percentage/actions/workflows/test.yml)
[![Coverage Status](https://coveralls.io/repos/github/mrcgrtz/postcss-opacity-percentage/badge.svg?branch=main)](https://coveralls.io/github/mrcgrtz/postcss-opacity-percentage?branch=main)
[![Install size](https://packagephobia.now.sh/badge?p=postcss-opacity-percentage)](https://packagephobia.now.sh/result?p=postcss-opacity-percentage)
[![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/sindresorhus/xo)
[![MIT license](https://img.shields.io/github/license/mrcgrtz/postcss-opacity-percentage.svg)](https://github.com/mrcgrtz/postcss-opacity-percentage/blob/main/LICENSE.md)

[PostCSS](https://github.com/postcss/postcss) plugin to transform [percentage-based opacity values](https://www.w3.org/TR/css-color-4/#transparency) to more compatible floating-point values.

## Install

Using [npm](https://www.npmjs.com/get-npm):

```bash
npm install --save-dev postcss postcss-opacity-percentage
```

Using [yarn](https://yarnpkg.com/):

```bash
yarn add --dev postcss postcss-opacity-percentage
```

## Example

```css
/* Input */
.foo {
  opacity: 45%;
}
```

```css
/* Output */
.foo {
  opacity: 0.45;
}
```

## Usage

```js
postcss([
  require('postcss-opacity-percentage'),
]);
```

See [PostCSS](https://github.com/postcss/postcss) documentation for examples for your environment.

### `postcss-preset-env`

If you are using [`postcss-preset-env@>=7.3.0`](https://github.com/csstools/postcss-plugins/blob/main/plugin-packs/postcss-preset-env/CHANGELOG.md#730-january-31-2022), you already have this plugin installed via this package.

## Options

### `preserve`

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

```js
// Keep the original notation
postcss([
  require('postcss-opacity-percentage')({preserve: true}),
]);
```

```css
/* Input */
.foo {
  opacity: 45%;
}
```

```css
/* Output */
.foo {
  opacity: 0.45;
  opacity: 45%;
}
```

## License

MIT © [Marc Görtz](https://marcgoertz.de/)

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