Immutable padding utilities are based on a global white space scale defined with custom properties. These can dramatically help reduce the size of large stylesheets and allow for greater flexibility and quicker iteration when designing in the browser.
Naming Convention
Due to the ubiquitous nature of setting padding, these utilities use a shorthand naming convention.
Shorthand | Description |
---|---|
p | Padding |
t | Top |
r | Right |
b | Bottom |
l | Left |
x | X-axis (left and right) |
y | Y-axis (top and bottom) |
n | Negative (margin only) |
0 | 0 reset |
1 | --space-1 (default .5rem) |
2 | --space-2 (default 1rem) |
3 | --space-3 (default 2rem) |
4 | --space-4 (default 4rem) |
Padding utilities are only available in symmetrical orientations. This is to normalize the spacing used around elements and maintain a consistent visual rhythm.
Box
To create a simple box component, use padding along with color utilities.
A simple box
Panel Header Panel Body Panel Footer
Padding should never be declared outside of these utilities. This is meant to help create consistency and avoid magic numbers. If, for some reason, the default white space scale does not suit your design, customize and extend it before use.