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.

ShorthandDescription
ppadding
ttop
rright
bbottom
lleft
xhorizontal, left & right
yvertical, top & bottom
00
14px
28px
316px
424px
532px
640px
748px
864px
980px
1096px
11112px
12128px

Note: The gray in the examples below represents the element, and the yellow 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.

View in Storybook

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.

View in Storybook

Extended directional padding

The extended directional padding scale starts from spacer 7 and goes up to 12. All directions and their responsive variants are supported, except for px.

View in Storybook

Responsive padding

All padding utilities can be adjusted per breakpoint using the following formula:
p-[direction]-[breakpoint]-[spacer]. Each responsive style is applied to the specified breakpoint and up.

View in Storybook

Responsive container padding

.p-responsive 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 equivalent of adding the .px-3 .px-sm-6 .px-lg-3 utility classes.

View in Storybook

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