Link

Padding

Padding utilities are based on a global spacing scale which helps keep horizontal and vertical spacing consistent. These utilities help us reduce the amount of custom CSS that could share the same properties, and allows to achieve many different page layouts using the same styles.

Shorthand

Since padding utilities have many variations and will be used in many places, we use a shorthand naming convention to help keep class names succinct.

Shorthand Description
p padding
t top
r right
b bottom
l left
x horizontal, left & right
y vertical, top & bottom
0 0
1 .25rem / 4px
2 .5rem / 8px
3 1rem / 16px
4 1.5rem / 24px
5 2rem / 32px
6 2.5rem / 40px

Note: The blue in the examples below represents the element, and the green represents the padding.

Uniform padding

Use uniform spacing utilities to apply equal padding to all sides of an element. These utilities can be used with a spacing scale from 0-6.

.p-0-fluid
.p-1-fluid
.p-2-fluid
.p-3-fluid
.p-4-fluid
.p-5-fluid
.p-6-fluid

Directional padding

Use directional utilities to apply padding to an individual side, or the X and Y axis of an element. Directional utilities can change or override default padding, and can be used with a spacing scale of 0-6.

.pt-3-fluid
.pr-3-fluid
.pb-3-fluid
.pl-3-fluid
.py-3-fluid
.px-3-fluid

Responsive padding

All padding utilities can be adjusted per breakpoint using the following formula:

p-[direction]-[breakpoint]-[spacer]-fluid

Each responsive style is applied to the specified breakpoint and up.

.px-sm-2-fluid .px-md-4-fluid

Responsive container padding

.p-responsive-fluid is a padding class that adds padding on the left and right sides of an element. It is intended to be used with container styles.

  • On 0 to sm screens, it gives the element padding of $spacer-3
  • On sm to lg screens it gives the element padding of $spacer-6
  • On lg and wider screens, it gives the element padding of $spacer-3

It’s the equvilent of adding the .px-3-fluid .px-sm-6-fluid .px-lg-3-fluid utility classes.

.p-responsive-fluid

Note: Since the example is shown in an iframe it won’t show the change to $spacer-3 for the lg breakpoint.