@csstools/postcss-image-function
Generate a solid-color image from any color
Last updated 3 months ago by romainmenke .
MIT-0 · Repository · Bugs · Original npm · Tarball · package.json
$ npm install @csstools/postcss-image-function 
SYNC missed versions from official npm registry.

PostCSS Image Function PostCSS Logo

npm install @csstools/postcss-image-function --save-dev

PostCSS Image Function lets you easily generate a solid-color image from any color following the CSS Images 4 Specification.

.foo {
	background-image: image(transparent);
}

.foo {
	--bg-image: image(transparent);
}

/* becomes */

.foo {
	background-image: linear-gradient(transparent,transparent);
}

.foo {
	--bg-image: linear-gradient(transparent,transparent);
}

Usage

Add PostCSS Image Function to your project:

npm install postcss @csstools/postcss-image-function --save-dev

Use it as a PostCSS plugin:

const postcss = require('postcss');
const postcssImageFunction = require('@csstools/postcss-image-function');

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

Options

preserve

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

postcssImageFunction({ preserve: true })
.foo {
	background-image: image(transparent);
}

.foo {
	--bg-image: image(transparent);
}

/* becomes */

.foo {
	background-image: linear-gradient(transparent,transparent);
	background-image: image(transparent);
}

.foo {
	--bg-image: linear-gradient(transparent,transparent);
}

@supports (background-image: image(red)) {
.foo {
	--bg-image: image(transparent);
}
}

Current Tags

  • 1.0.8                                ...           latest (10 days ago)

9 Versions

  • 1.0.8                                ...           10 days ago
  • 1.0.7                                ...           a month ago
  • 1.0.6                                ...           2 months ago
  • 1.0.5                                ...           2 months ago
  • 1.0.4                                ...           2 months ago
  • 1.0.3                                ...           3 months ago
  • 1.0.2                                ...           3 months ago
  • 1.0.1                                ...           5 months ago
  • 1.0.0                                ...           6 months ago
Downloads
Total 10
Today 0
This Week 0
This Month 10
Last Day 0
Last Week 0
Last Month 0
Dev Dependencies (0)
None
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE