6.1.0 • Published 5 months ago

postcss-color-image v6.1.0

Weekly downloads
2
License
ISC
Repository
github
Last release
5 months ago

PostCSS Solid-Color Image

NPM

This PostCSS plugin lets you use a solid color as an image, following the CSS Images specification.

.box {
	background: image(red);
}

/* becomes */

.box {
	background: linear-gradient(red 0 0);
}

Install

npm install postcss-color-image

Usage

import postcss from 'postcss';
import colorImage from 'postcss-color-image';
// OR
const postcss = require('postcss');
const colorImage = require('postcss-color-image');

await postcss([colorImage]).process(YOUR_CSS);

Options

compat: true

Instead of adding a double-position color stop, duplicate the color in the output gradient for wider browser support.

.box {
	background: linear-gradient(red, red);
}

preserve: true

Keep the original CSS declaration alongside the transformed one.

.box {
	background: linear-gradient(red 0 0);
	background: image(red);
}