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
| Class | Properties |
|---|---|
.p-0 | padding: 0; |
.p-1 | padding: 0.25rem; /* 4px */ |
.p-2 | padding: 0.5rem; /* 8px */ |
.p-3 | padding: 0.75rem; /* 12px */ |
.p-4 | padding: 1rem; /* 16px */ |
.p-5 | padding: 1.25rem; /* 20px */ |
.p-6 | padding: 1.5rem; /* 24px */ |
.p-7 | padding: 1.75rem; /* 28px */ |
.p-8 | padding: 2rem; /* 32px */ |
.p-9 | padding: 2.25rem; /* 36px */ |
.p-10 | padding: 2.5rem; /* 40px */ |
.p-11 | padding: 2.75rem; /* 44px */ |
.p-12 | padding: 3rem; /* 48px */ |
.p-14 | padding: 3.5rem; /* 56px */ |
.p-16 | padding: 4rem; /* 64px */ |
.p-20 | padding: 5rem; /* 80px */ |
.px-0 | padding-left: 0; padding-right: 0; |
.px-1 | padding-left: 0.25rem; /* 4px */ padding-right: 0.25rem; /* 4px */ |
.px-2 | padding-left: 0.5rem; /* 8px */ padding-right: 0.5rem; /* 8px */ |
.px-3 | padding-left: 0.75rem; /* 12px */ padding-right: 0.75rem; /* 12px */ |
.px-4 | padding-left: 1rem; /* 16px */ padding-right: 1rem; /* 16px */ |
.px-5 | padding-left: 1.25rem; /* 20px */ padding-right: 1.25rem; /* 20px */ |
.px-6 | padding-left: 1.5rem; /* 24px */ padding-right: 1.5rem; /* 24px */ |
.px-7 | padding-left: 1.75rem; /* 28px */ padding-right: 1.75rem; /* 28px */ |
.px-8 | padding-left: 2rem; /* 32px */ padding-right: 2rem; /* 32px */ |
.px-9 | padding-left: 2.25rem; /* 36px */ padding-right: 2.25rem; /* 36px */ |
.px-10 | padding-left: 2.5rem; /* 40px */ padding-right: 2.5rem; /* 40px */ |
.px-11 | padding-left: 2.75rem; /* 44px */ padding-right: 2.75rem; /* 44px */ |
.px-12 | padding-left: 3rem; /* 48px */ padding-right: 3rem; /* 48px */ |
.px-14 | padding-left: 3.5rem; /* 56px */ padding-right: 3.5rem; /* 56px */ |
.px-16 | padding-left: 4rem; /* 64px */ padding-right: 4rem; /* 64px */ |
.px-20 | padding-left: 5rem; /* 80px */ padding-right: 5rem; /* 80px */ |
.py-0 | padding-top: 0; padding-bottom: 0; |
.py-1 | padding-top: 0.25rem; /* 4px */ padding-bottom: 0.25rem; /* 4px */ |
.py-2 | padding-top: 0.5rem; /* 8px */ padding-bottom: 0.5rem; /* 8px */ |
.py-3 | padding-top: 0.75rem; /* 12px */ padding-bottom: 0.75rem; /* 12px */ |
.py-4 | padding-top: 1rem; /* 16px */ padding-bottom: 1rem; /* 16px */ |
.py-5 | padding-top: 1.25rem; /* 20px */ padding-bottom: 1.25rem; /* 20px */ |
.py-6 | padding-top: 1.5rem; /* 24px */ padding-bottom: 1.5rem; /* 24px */ |
.py-7 | padding-top: 1.75rem; /* 28px */ padding-bottom: 1.75rem; /* 28px */ |
.py-8 | padding-top: 2rem; /* 32px */ padding-bottom: 2rem; /* 32px */ |
.py-9 | padding-top: 2.25rem; /* 36px */ padding-bottom: 2.25rem; /* 36px */ |
.py-10 | padding-top: 2.5rem; /* 40px */ padding-bottom: 2.5rem; /* 40px */ |
.py-11 | padding-top: 2.75rem; /* 44px */ padding-bottom: 2.75rem; /* 44px */ |
.py-12 | padding-top: 3rem; /* 48px */ padding-bottom: 3rem; /* 48px */ |
.py-14 | padding-top: 3.5rem; /* 56px */ padding-bottom: 3.5rem; /* 56px */ |
.py-16 | padding-top: 4rem; /* 64px */ padding-bottom: 4rem; /* 64px */ |
.py-20 | padding-top: 5rem; /* 80px */ padding-bottom: 5rem; /* 80px */ |
.pt-0 | padding-top: 0; |
.pt-1 | padding-top: 0.25rem; /* 4px */ |
.pt-2 | padding-top: 0.5rem; /* 8px */ |
.pt-3 | padding-top: 0.75rem; /* 12px */ |
.pt-4 | padding-top: 1rem; /* 16px */ |
.pt-5 | padding-top: 1.25rem; /* 20px */ |
.pt-6 | padding-top: 1.5rem; /* 24px */ |
.pt-7 | padding-top: 1.75rem; /* 28px */ |
.pt-8 | padding-top: 2rem; /* 32px */ |
.pt-9 | padding-top: 2.25rem; /* 36px */ |
.pt-10 | padding-top: 2.5rem; /* 40px */ |
.pt-11 | padding-top: 2.75rem; /* 44px */ |
.pt-12 | padding-top: 3rem; /* 48px */ |
.pt-14 | padding-top: 3.5rem; /* 56px */ |
.pt-16 | padding-top: 4rem; /* 64px */ |
.pt-20 | padding-top: 5rem; /* 80px */ |
.pb-0 | padding-bottom: 0; |
.pb-1 | padding-bottom: 0.25rem; /* 4px */ |
.pb-2 | padding-bottom: 0.5rem; /* 8px */ |
.pb-3 | padding-bottom: 0.75rem; /* 12px */ |
.pb-4 | padding-bottom: 1rem; /* 16px */ |
.pb-5 | padding-bottom: 1.25rem; /* 20px */ |
.pb-6 | padding-bottom: 1.5rem; /* 24px */ |
.pb-7 | padding-bottom: 1.75rem; /* 28px */ |
.pb-8 | padding-bottom: 2rem; /* 32px */ |
.pb-9 | padding-bottom: 2.25rem; /* 36px */ |
.pb-10 | padding-bottom: 2.5rem; /* 40px */ |
.pb-11 | padding-bottom: 2.75rem; /* 44px */ |
.pb-12 | padding-bottom: 3rem; /* 48px */ |
.pb-14 | padding-bottom: 3.5rem; /* 56px */ |
.pb-16 | padding-bottom: 4rem; /* 64px */ |
.pb-20 | padding-bottom: 5rem; /* 80px */ |
.ps-0 | padding-left: 0; |
.ps-1 | padding-left: 0.25rem; /* 4px */ |
.ps-2 | padding-left: 0.5rem; /* 8px */ |
.ps-3 | padding-left: 0.75rem; /* 12px */ |
.ps-4 | padding-left: 1rem; /* 16px */ |
.ps-5 | padding-left: 1.25rem; /* 20px */ |
.ps-6 | padding-left: 1.5rem; /* 24px */ |
.ps-7 | padding-left: 1.75rem; /* 28px */ |
.ps-8 | padding-left: 2rem; /* 32px */ |
.ps-9 | padding-left: 2.25rem; /* 36px */ |
.ps-10 | padding-left: 2.5rem; /* 40px */ |
.ps-11 | padding-left: 2.75rem; /* 44px */ |
.ps-12 | padding-left: 3rem; /* 48px */ |
.ps-14 | padding-left: 3.5rem; /* 56px */ |
.ps-16 | padding-left: 4rem; /* 64px */ |
.ps-20 | padding-left: 5rem; /* 80px */ |
.pe-0 | padding-right: 0; |
.pe-1 | padding-right: 0.25rem; /* 4px */ |
.pe-2 | padding-right: 0.5rem; /* 8px */ |
.pe-3 | padding-right: 0.75rem; /* 12px */ |
.pe-4 | padding-right: 1rem; /* 16px */ |
.pe-5 | padding-right: 1.25rem; /* 20px */ |
.pe-6 | padding-right: 1.5rem; /* 24px */ |
.pe-7 | padding-right: 1.75rem; /* 28px */ |
.pe-8 | padding-right: 2rem; /* 32px */ |
.pe-9 | padding-right: 2.25rem; /* 36px */ |
.pe-10 | padding-right: 2.5rem; /* 40px */ |
.pe-11 | padding-right: 2.75rem; /* 44px */ |
.pe-12 | padding-right: 3rem; /* 48px */ |
.pe-14 | padding-right: 3.5rem; /* 56px */ |
.pe-16 | padding-right: 4rem; /* 64px */ |
.pe-20 | padding-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 setpadding-topb- for classes that setpadding-bottoms- (start) for classes that setpadding-leftin LTR,padding-rightin RTLe- (end) for classes that setpadding-rightin LTR, orpadding-leftin RTLx- for classes that set both*-leftand*-righty- for classes that set both*-topand*-bottom- blank - for classes that set a
paddingon all 4 sides of the element
Where size is one of:
0- for classes that eliminate thepaddingby setting it to01- (by default) for classes that set thepaddingto$spacer * .252- (by default) for classes that set thepaddingto$spacer * .53- (by default) for classes that set thepaddingto$spacer4- (by default) for classes that set thepaddingto$spacer * 1.55- (by default) for classes that set thepaddingto$spacer * 36- (by extended) for classes that set thepaddingto$spacer * 47- (by extended) for classes that set thepaddingto$spacer * 58- (by extended) for classes that set thepaddingto$spacer * 69- (by extended) for classes that set thepaddingto$spacer * 710- (by extended) for classes that set thepaddingto$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.
<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.
<div class="px-6 ...">px-6</div>
Add vertical padding
Control the vertical padding of an element using the py-{size} utilities.
<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.
<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.
<div class="py-sm-3 py-md-5 ...">py-sm-3 py-md-5</div>