PostCSS Short Spacing
PostCSS Short Spacing lets you omit sides within margin
and padding
properties in CSS.
section { margin: 1em *;} /* becomes */ section { margin-top: 1em; margin-bottom: 1em;}
Supported properties include margin
, margin-block
, margin-inline
,
margin-start
, margin-end
, padding
, padding-block
, padding-inline
,
padding-start
, and padding-end
.
Usage
Add PostCSS Short Spacing to your project:
npm install postcss-short-spacing --save-dev
Use PostCSS Short Spacing to process your CSS:
const postcssShortSpacing = ; postcssShortSpacing;
Or use it as a PostCSS plugin:
const postcss = ;const postcssShortSpacing = ; ;
PostCSS Short Spacing 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-margin
.
;
body { -x-margin: 1em *;} /* becomes */ section { margin-top: 1em; margin-bottom: 1em;}
skip
The skip
option defines the skip token used to ignore portions of the
shorthand.
;
body { -x-margin: 1em -;} /* becomes */ section { margin-top: 1em; margin-bottom: 1em;}