postcss-button


francoisromain.github.io/postcss-button
A PostCSS plugin to create buttons.
This plugin outputs a lot of the repetitive css code necessary to create clean buttons. It also uses box-shadow
to create borders which does not break the vertical rhythm.
Examples
There are two ways to declare a button:
With specific declarations
.my-button-class {
button-color: skyblue white white;
button-background: white skyblue silver;
button-border: 4px skyblue skyblue silver;
button-class: active disabled true;
}
With a configuration
@button my-button-name {
button-color: orange;
button-color-active: white;
button-color-hover: white;
button-background-color: white;
button-background-color-active: silver;
button-background-color-hover: orange;
button-border-width: 1px;
button-border-color: silver;
button-border-color-active: silver;
button-border-color-hover: orange;
button-class-active: active;
button-class-disabled: disabled;
button-class-parent: true;
}
.my-button-class {
button: my-button-name;
}
01: input, output, markup, demo
02: input, output, markup, demo
Installation
Install the npm package:
npm install --save-dev postcss postcss-button
Require the PostCSS plugin:
postcss([require("postcss-button")]);
See PostCSS docs to setup with Gulp, Grunt, Webpack, npm scripts…
Usage
With a configuration (optional)
@button ([name]) {
[button-css-rules…]
}
.my-class {
button: [name];
}
Without a configuration
.my-class {
[button-css-rules…]
}
Css rules
Color
button-color-active: [color];
button-color-hover: [color];
button-color: [color] ([color-active]) ([color-hover]);
Background color
button-background-active: [color];
button-background-hover: [color];
button-background: [background-color] ([background-color-active])
([background-color-hover]);
Border
button-border-width: [width];
button-border-color: [color];
button-border-color-active: [color];
button-border-color-hover: [color];
button-border: [border-width] ([border-color]) ([border-color-active])
([border-color-hover]);
Classes
button-class-active: [class-name];
button-class-disabled: [class-name];
button-class-parent: [boolean];
button-class: [active] ([disabled]) ([parent]);
Missing declarations fallback to the default settings.