Spacing helpers
Friendly spacing to a element with short code
Set the friendly margin as m* and padding as p* value to an element or part of the side by writing short code with all directions:
*tfor top*rfor right*bfor bottom*lfor left*xhorizontally for both left and right*yvertically for both top and bottom
You can combine a margin/padding prefix with a direciton suffix. For example:
- for a
margin-top, usemt-* - for a
padding-bottom, usepb-* - for both
margin-leftandmargin-right, usemx-* - for both
padding-topandpadding-bottom, usepy-* - for a value negative use
*-n*
Each of these property-direction combinations needs to be appended with one of 11 value suffixes:
| Suffix | Value |
|---|---|
*-0 | 0 |
*-1 | 0.5rem |
*-2 | 1rem |
*-3 | 1.5rem |
*-4 | 2rem |
*-5 | 3rem |
*-n1 | -0.5rem |
*-n2 | -1rem |
*-n3 | -1.5rem |
*-n4 | -2rem |
*-n5 | -3rem |
Configuration
Because every developer has their own preferences, and to satisfy Buval's customization features, it's possible to specify your own class name shortcuts as well as the spacing values.
For example, if you wanted:
- margin to be abbreviated to
mg - padding to be totally excluded
-
and to only have 3 values: "small" at
10px, "medium" at30px, and "large" at60px
You can simplify the CSS output by customizing these SCSS variables:
$spacing-shortcuts: ("margin": "mg");
$spacing-values: ("small": 10px, "medium": 30px, "large": 60px); | Property | Shortcut | Classes ↓ | ||||||
|---|---|---|---|---|---|---|---|---|
| Values → | 10px | 30px | 60px | |||||
margin-top | mgt | mgt-small | mgt-medium | mgt-large | ||||
margin-right | mgr | mgr-small | mgr-medium | mgr-large | ||||
margin-bottom | mgb | mgb-small | mgb-medium | mgb-large | ||||
margin-left | mgl | mgl-small | mgl-medium | mgl-large | ||||
margin-left and margin-right | mgx | mgx-small | mgx-medium | mgx-large | ||||
margin-top and margin-bottom | mgy | mgy-small | mgy-medium | mgy-large | ||||
By customizing the output, you've narrowed down the list of spacing helpers only 26.