Padding

Utilities for controlling an element’s padding.

Assign responsive-friendly padding values to an element or a subset of its sides with shorthand classes. Includes support for individual properties, all properties, and vertical and horizontal properties. Classes are built from a default Sass map ranging from .25rem to 9rem.

Quick reference

ClassProperties
.p-0padding: 0;
.p-1padding: 0.25rem; /* 4px */
.p-2padding: 0.5rem; /* 8px */
.p-3padding: 0.75rem; /* 12px */
.p-4padding: 1rem; /* 16px */
.p-5padding: 1.25rem; /* 20px */
.p-6padding: 1.5rem; /* 24px */
.p-7padding: 1.75rem; /* 28px */
.p-8padding: 2rem; /* 32px */
.p-9padding: 2.25rem; /* 36px */
.p-10padding: 2.5rem; /* 40px */
.p-11padding: 2.75rem; /* 44px */
.p-12padding: 3rem; /* 48px */
.p-14padding: 3.5rem; /* 56px */
.p-16padding: 4rem; /* 64px */
.p-20padding: 5rem; /* 80px */
.px-0padding-left: 0;
padding-right: 0;
.px-1padding-left: 0.25rem; /* 4px */
padding-right: 0.25rem; /* 4px */
.px-2padding-left: 0.5rem; /* 8px */
padding-right: 0.5rem; /* 8px */
.px-3padding-left: 0.75rem; /* 12px */
padding-right: 0.75rem; /* 12px */
.px-4padding-left: 1rem; /* 16px */
padding-right: 1rem; /* 16px */
.px-5padding-left: 1.25rem; /* 20px */
padding-right: 1.25rem; /* 20px */
.px-6padding-left: 1.5rem; /* 24px */
padding-right: 1.5rem; /* 24px */
.px-7padding-left: 1.75rem; /* 28px */
padding-right: 1.75rem; /* 28px */
.px-8padding-left: 2rem; /* 32px */
padding-right: 2rem; /* 32px */
.px-9padding-left: 2.25rem; /* 36px */
padding-right: 2.25rem; /* 36px */
.px-10padding-left: 2.5rem; /* 40px */
padding-right: 2.5rem; /* 40px */
.px-11padding-left: 2.75rem; /* 44px */
padding-right: 2.75rem; /* 44px */
.px-12padding-left: 3rem; /* 48px */
padding-right: 3rem; /* 48px */
.px-14padding-left: 3.5rem; /* 56px */
padding-right: 3.5rem; /* 56px */
.px-16padding-left: 4rem; /* 64px */
padding-right: 4rem; /* 64px */
.px-20padding-left: 5rem; /* 80px */
padding-right: 5rem; /* 80px */
.py-0padding-top: 0;
padding-bottom: 0;
.py-1padding-top: 0.25rem; /* 4px */
padding-bottom: 0.25rem; /* 4px */
.py-2padding-top: 0.5rem; /* 8px */
padding-bottom: 0.5rem; /* 8px */
.py-3padding-top: 0.75rem; /* 12px */
padding-bottom: 0.75rem; /* 12px */
.py-4padding-top: 1rem; /* 16px */
padding-bottom: 1rem; /* 16px */
.py-5padding-top: 1.25rem; /* 20px */
padding-bottom: 1.25rem; /* 20px */
.py-6padding-top: 1.5rem; /* 24px */
padding-bottom: 1.5rem; /* 24px */
.py-7padding-top: 1.75rem; /* 28px */
padding-bottom: 1.75rem; /* 28px */
.py-8padding-top: 2rem; /* 32px */
padding-bottom: 2rem; /* 32px */
.py-9padding-top: 2.25rem; /* 36px */
padding-bottom: 2.25rem; /* 36px */
.py-10padding-top: 2.5rem; /* 40px */
padding-bottom: 2.5rem; /* 40px */
.py-11padding-top: 2.75rem; /* 44px */
padding-bottom: 2.75rem; /* 44px */
.py-12padding-top: 3rem; /* 48px */
padding-bottom: 3rem; /* 48px */
.py-14padding-top: 3.5rem; /* 56px */
padding-bottom: 3.5rem; /* 56px */
.py-16padding-top: 4rem; /* 64px */
padding-bottom: 4rem; /* 64px */
.py-20padding-top: 5rem; /* 80px */
padding-bottom: 5rem; /* 80px */
.pt-0padding-top: 0;
.pt-1padding-top: 0.25rem; /* 4px */
.pt-2padding-top: 0.5rem; /* 8px */
.pt-3padding-top: 0.75rem; /* 12px */
.pt-4padding-top: 1rem; /* 16px */
.pt-5padding-top: 1.25rem; /* 20px */
.pt-6padding-top: 1.5rem; /* 24px */
.pt-7padding-top: 1.75rem; /* 28px */
.pt-8padding-top: 2rem; /* 32px */
.pt-9padding-top: 2.25rem; /* 36px */
.pt-10padding-top: 2.5rem; /* 40px */
.pt-11padding-top: 2.75rem; /* 44px */
.pt-12padding-top: 3rem; /* 48px */
.pt-14padding-top: 3.5rem; /* 56px */
.pt-16padding-top: 4rem; /* 64px */
.pt-20padding-top: 5rem; /* 80px */
.pb-0padding-bottom: 0;
.pb-1padding-bottom: 0.25rem; /* 4px */
.pb-2padding-bottom: 0.5rem; /* 8px */
.pb-3padding-bottom: 0.75rem; /* 12px */
.pb-4padding-bottom: 1rem; /* 16px */
.pb-5padding-bottom: 1.25rem; /* 20px */
.pb-6padding-bottom: 1.5rem; /* 24px */
.pb-7padding-bottom: 1.75rem; /* 28px */
.pb-8padding-bottom: 2rem; /* 32px */
.pb-9padding-bottom: 2.25rem; /* 36px */
.pb-10padding-bottom: 2.5rem; /* 40px */
.pb-11padding-bottom: 2.75rem; /* 44px */
.pb-12padding-bottom: 3rem; /* 48px */
.pb-14padding-bottom: 3.5rem; /* 56px */
.pb-16padding-bottom: 4rem; /* 64px */
.pb-20padding-bottom: 5rem; /* 80px */
.ps-0padding-left: 0;
.ps-1padding-left: 0.25rem; /* 4px */
.ps-2padding-left: 0.5rem; /* 8px */
.ps-3padding-left: 0.75rem; /* 12px */
.ps-4padding-left: 1rem; /* 16px */
.ps-5padding-left: 1.25rem; /* 20px */
.ps-6padding-left: 1.5rem; /* 24px */
.ps-7padding-left: 1.75rem; /* 28px */
.ps-8padding-left: 2rem; /* 32px */
.ps-9padding-left: 2.25rem; /* 36px */
.ps-10padding-left: 2.5rem; /* 40px */
.ps-11padding-left: 2.75rem; /* 44px */
.ps-12padding-left: 3rem; /* 48px */
.ps-14padding-left: 3.5rem; /* 56px */
.ps-16padding-left: 4rem; /* 64px */
.ps-20padding-left: 5rem; /* 80px */
.pe-0padding-right: 0;
.pe-1padding-right: 0.25rem; /* 4px */
.pe-2padding-right: 0.5rem; /* 8px */
.pe-3padding-right: 0.75rem; /* 12px */
.pe-4padding-right: 1rem; /* 16px */
.pe-5padding-right: 1.25rem; /* 20px */
.pe-6padding-right: 1.5rem; /* 24px */
.pe-7padding-right: 1.75rem; /* 28px */
.pe-8padding-right: 2rem; /* 32px */
.pe-9padding-right: 2.25rem; /* 36px */
.pe-10padding-right: 2.5rem; /* 40px */
.pe-11padding-right: 2.75rem; /* 44px */
.pe-12padding-right: 3rem; /* 48px */
.pe-14padding-right: 3.5rem; /* 56px */
.pe-16padding-right: 4rem; /* 64px */
.pe-20padding-right: 5rem; /* 80px */

Overview

The padding utilities that apply to all breakpoints, from xs to xxl, have no breakpoint abbreviation in them. This is because those classes are applied from min-width: 0 and up, and thus are not bound by a media query. The remaining breakpoints, however, do include a breakpoint abbreviation.

The classes are named using the format {property}{sides}-{size} for xs and {property}{sides}-{breakpoint}-{size} for sm, md, lg, xl, and xxl.

Where property is p - for classes that set padding:

Where sides is one of:

  • t - for classes that set padding-top
  • b - for classes that set padding-bottom
  • s - (start) for classes that set padding-left in LTR,padding-right in RTL
  • e - (end) for classes that set padding-right in LTR, or padding-left in RTL
  • x - for classes that set both *-left and *-right
  • y - for classes that set both *-top and *-bottom
  • blank - for classes that set a padding on all 4 sides of the element

Where size is one of:

  • 0 - for classes that eliminate the padding by setting it to 0
  • 1 - (by default) for classes that set the padding to $spacer * .25
  • 2 - (by default) for classes that set the padding to $spacer * .5
  • 3 - (by default) for classes that set the padding to $spacer
  • 4 - (by default) for classes that set the padding to $spacer * 1.5
  • 5 - (by default) for classes that set the padding to $spacer * 3
  • 6 - (by extended) for classes that set the padding to $spacer * 4
  • 7 - (by extended) for classes that set the padding to $spacer * 5
  • 8 - (by extended) for classes that set the padding to $spacer * 6
  • 9 - (by extended) for classes that set the padding to $spacer * 7
  • 10 - (by extended) for classes that set the padding to $spacer * 8

(You can add more sizes by adding entries to the $spacers Sass map variable.)

Basic usage

Add padding to a single side

Use the p{t|s|b|e}-{size} utilities to apply padding to an individual side, or the X and Y axis of an element.

For example, pt-4 would add 1.5rem of padding to the top of an element, pe-3 would add 1rem of padding to the right of an element, pb-5 would add 3rem of padding to the bottom of an element, and ps-2 would add 0.5rem of padding to the left of an element.

pt-4
pe-3
pb-5
ps-2
<div class="pt-4 ...">pt-4</div>
<div class="pe-3 ...">pe-3</div>
<div class="pb-5 ...">pb-5</div>
<div class="ps-2 ...">ps-2</div>

Add horizontal padding

Control the horizontal padding of an element using the px-{size} utilities.

px-6
<div class="px-6 ...">px-6</div>

Add vertical padding

Control the vertical padding of an element using the py-{size} utilities.

py-6
<div class="py-6 ...">py-6</div>

Add padding to all sides

Control the padding on all sides of an element using the p-{size} utilities.

p-5
<div class="p-5 ...">p-5</div>

Breakpoints

All padding utilities that supports responsive at specific breakpoints, using the following format {property}{sides}-{breakpoint}-{size} for xs, sm, md, lg, xl, and xxl.

For example, use py-md-5 to apply the py-5 utility at only medium screen sizes and above.

py-sm-3 py-md-5
<div class="py-sm-3 py-md-5 ...">py-sm-3 py-md-5</div>