postcss-short-border
v4.0.0
Published
Define multiple edges, styles, and colors inside the border property in CSS
Downloads
13,651
Readme
PostCSS Short Border
PostCSS Short Border lets you omit sides within border-
properties in CSS.
It also lets you fully define individual values on the border
property using
dividers (/
).
.example-1 {
border-color: blue blue *;
}
.example-2 {
border-width: 1px *;
}
.example-3 {
border: 1px 2px / solid / red orange;
}
/* becomes */
.example-1 {
border-top-color: blue;
border-right-color: blue;
border-left-color: blue;
}
.example-2 {
border-top-width: 1px;
border-bottom-width: 1px;
}
.example-3 {
border-width: 1px 2px;
border-style: solid;
border-color: red orange;
}
Usage
Add PostCSS Short Border to your project:
npm install postcss-short-border --save-dev
Use PostCSS Short Border to process your CSS:
const postcssShortBorder = require('postcss-short-border');
postcssShortBorder.process(YOUR_CSS /*, processOptions, pluginOptions */);
Or use it as a PostCSS plugin:
const postcss = require('postcss');
const postcssShortBorder = require('postcss-short-border');
postcss([
postcssShortBorder(/* pluginOptions */)
]).process(YOUR_CSS /*, processOptions */);
PostCSS Short Border runs in all Node environments, with special instructions for:
| Node | PostCSS CLI | Webpack | Create React App | Gulp | Grunt | | --- | --- | --- | --- | --- | --- |
Options
prefix
The prefix
option defines a prefix required by properties being transformed.
Wrapping dashes are automatically applied, so that x
would transform
-x-border
.
postcssShortBorder({ prefix: 'x' });
.example-1 {
-x-border-color: blue blue *;
}
/* becomes */
.example-1 {
border-top-color: blue;
border-right-color: blue;
border-left-color: blue;
}
skip
The skip
option defines the skip token used to ignore portions of the
shorthand.
postcssShortBorder({ skip: '-' });
.example-1 {
border-color: blue blue -;
}
/* becomes */
.example-1 {
border-top-color: blue;
border-right-color: blue;
border-left-color: blue;
}