postcss-short-border

4.0.0 • Public • Published

PostCSS Short Border PostCSS

NPM Version Build Status Support Chat

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;
}

Package Sidebar

Install

npm i postcss-short-border

Weekly Downloads

3,116

Version

4.0.0

License

CC0-1.0

Unpacked Size

27.1 kB

Total Files

8

Last publish

Collaborators

  • romainmenke
  • alaguna
  • jonathantneal