Define background-color within the color property in CSS
npm install postcss-short-color[![NPM Version][npm-img]][npm-url]
[![Build Status][cli-img]][cli-url]
[![Support Chat][git-img]][git-url]
[PostCSS Short Color] lets you define background-color within the color
property in CSS.
``pcss
header {
color: #abccfc #212231;
}
/ becomes /
header {
background-color: #212231;
color: #abccfc;
}
`
Add [PostCSS Short Color] to your project:
`bash`
npm install postcss-short-color --save-dev
Use [PostCSS Short Color] to process your CSS:
`js
const postcssShortColor = require('postcss-short-color');
postcssShortColor.process(YOUR_CSS /, processOptions, pluginOptions /);
`
Or use it as a [PostCSS] plugin:
`js
const postcss = require('postcss');
const postcssShortColor = require('postcss-short-color');
postcss([
postcssShortColor(/ pluginOptions /)
]).process(YOUR_CSS /, processOptions /);
`
[PostCSS Short Color] runs in all Node environments, with special instructions for:
| Node | PostCSS CLI | Webpack | Create React App | Gulp | Grunt |
| --- | --- | --- | --- | --- | --- |
#### prefix
The prefix option defines a prefix required by properties being transformed.x
Wrapping dashes are automatically applied, so that would transform-x-color.
`js`
postcssShortColor({ prefix: 'x' });
`pcss
header {
-x-color: #abccfc #212231;
}
/ becomes /
header {
background-color: #212231;
color: #abccfc;
}
`
#### skip
The skip option defines the skip token used to ignore portions of the
shorthand.
`js`
postcssShortColor({ skip: '-' });
`pcss
header {
color: - #212231;
}
/ becomes /
header {
background-color: #212231;
}
``
[cli-img]: https://img.shields.io/travis/jonathantneal/postcss-short-color.svg
[cli-url]: https://travis-ci.org/jonathantneal/postcss-short-color
[git-img]: https://img.shields.io/badge/support-chat-blue.svg
[git-url]: https://gitter.im/postcss/postcss
[npm-img]: https://img.shields.io/npm/v/postcss-short-color.svg
[npm-url]: https://www.npmjs.com/package/postcss-short-color
[PostCSS]: https://github.com/postcss/postcss
[PostCSS Short Color]: https://github.com/jonathantneal/postcss-short-color