Overview
Use padding utilities to control the space inside elements. Padding creates space between an element’s content and its border. These utilities work with a consistent 4px scale and include both static and fluid variants for responsive designs.Spacing Scale
All padding utilities follow a consistent 4px scale for predictable layouts.Spacing Scale
| 0 | 0px | No spacing |
| 1 | 4px | Fine adjustments |
| 2 | 8px | Small spacing |
| 3 | 12px | Medium spacing |
| 4 | 16px | Standard spacing |
| 6 | 24px | Large spacing |
| 8 | 32px | Extra large spacing |
| 12 | 48px | Section spacing |
All Sides Padding
Apply padding to all sides of an element at once.All Sides Padding
.p-0 | 0 | padding: 0; | No padding |
.p-1 | 4px | padding: 4px; | Small padding |
.p-2 | 8px | padding: 8px; | Small padding |
.p-3 | 12px | padding: 12px; | Medium padding |
.p-4 | 16px | padding: 16px; | Standard padding |
.p-6 | 24px | padding: 24px; | Large padding |
.p-8 | 32px | padding: 32px; | Extra large padding |
.p-12 | 48px | padding: 48px; | Section padding |
Examples
Vertical Padding
Control top and bottom padding independently.Top Padding
Top Padding
.pt-0 | 0 | padding-top: 0; | No top padding |
.pt-1 | 4px | padding-top: 4px; | Small top padding |
.pt-2 | 8px | padding-top: 8px; | Small top padding |
.pt-3 | 12px | padding-top: 12px; | Medium top padding |
.pt-4 | 16px | padding-top: 16px; | Standard top padding |
.pt-6 | 24px | padding-top: 24px; | Large top padding |
.pt-8 | 32px | padding-top: 32px; | Extra large top padding |
Bottom Padding
Bottom Padding
.pb-0 | 0 | padding-bottom: 0; | No bottom padding |
.pb-1 | 4px | padding-bottom: 4px; | Small bottom padding |
.pb-2 | 8px | padding-bottom: 8px; | Small bottom padding |
.pb-3 | 12px | padding-bottom: 12px; | Medium bottom padding |
.pb-4 | 16px | padding-bottom: 16px; | Standard bottom padding |
.pb-6 | 24px | padding-bottom: 24px; | Large bottom padding |
.pb-8 | 32px | padding-bottom: 32px; | Extra large bottom padding |
Examples
Horizontal Padding
Control left and right padding together.Horizontal Padding
.px-2 | Horizontal | 8px | padding-left: 8px; padding-right: 8px; | Small horizontal padding |
.px-3 | Horizontal | 12px | padding-left: 12px; padding-right: 12px; | Medium horizontal padding |
.px-4 | Horizontal | 16px | padding-left: 16px; padding-right: 16px; | Standard horizontal padding |
.px-6 | Horizontal | 24px | padding-left: 24px; padding-right: 24px; | Large horizontal padding |
.px-8 | Horizontal | 32px | padding-left: 32px; padding-right: 32px; | Extra large horizontal padding |
Vertical Padding
Control top and bottom padding together.Vertical Padding
.py-2 | Vertical | 8px | padding-top: 8px; padding-bottom: 8px; | Small vertical padding |
.py-3 | Vertical | 12px | padding-top: 12px; padding-bottom: 12px; | Medium vertical padding |
.py-4 | Vertical | 16px | padding-top: 16px; padding-bottom: 16px; | Standard vertical padding |
.py-6 | Vertical | 24px | padding-top: 24px; padding-bottom: 24px; | Large vertical padding |
.py-8 | Vertical | 32px | padding-top: 32px; padding-bottom: 32px; | Extra large vertical padding |
Examples
Fluid Padding
Fluid padding utilities useclamp() to scale smoothly between mobile and desktop sizes. They’re perfect for hero sections, marketing pages, and responsive layouts that need to adapt automatically.
All Sides Fluid Padding
Fluid Padding Utilities
| Class | Clamp Expression | Mobile → Desktop |
|---|---|---|
.p-fluid-1 | clamp(0.25rem, calc(0.21rem + 0.09vw), 0.31rem) | 4px → 5px |
.p-fluid-2 | clamp(0.5rem, calc(0.43rem + 0.18vw), 0.63rem) | 8px → 10px |
.p-fluid-3 | clamp(0.75rem, calc(0.64rem + 0.27vw), 0.94rem) | 12px → 15px |
.p-fluid-4 | clamp(1rem, calc(0.85rem + 0.37vw), 1.25rem) | 16px → 20px |
.p-fluid-6 | clamp(1.5rem, calc(1.28rem + 0.56vw), 1.88rem) | 24px → 30px |
.p-fluid-8 | clamp(2rem, calc(1.71rem + 0.74vw), 2.5rem) | 32px → 40px |
.p-fluid-12 | clamp(3rem, calc(2.56rem + 1.1vw), 3.75rem) | 48px → 60px |
Fluid Padding Top/Bottom
Fluid Padding Top
| Class | Clamp Expression | Mobile → Desktop |
|---|---|---|
.pt-fluid-1 | clamp(0.25rem, calc(0.21rem + 0.09vw), 0.31rem) | 4px → 5px |
.pt-fluid-2 | clamp(0.5rem, calc(0.43rem + 0.18vw), 0.63rem) | 8px → 10px |
.pt-fluid-3 | clamp(0.75rem, calc(0.64rem + 0.27vw), 0.94rem) | 12px → 15px |
.pt-fluid-4 | clamp(1rem, calc(0.85rem + 0.37vw), 1.25rem) | 16px → 20px |
.pt-fluid-6 | clamp(1.5rem, calc(1.28rem + 0.56vw), 1.88rem) | 24px → 30px |
.pt-fluid-8 | clamp(2rem, calc(1.71rem + 0.74vw), 2.5rem) | 32px → 40px |
Fluid Padding Bottom
| Class | Clamp Expression | Mobile → Desktop |
|---|---|---|
.pb-fluid-1 | clamp(0.25rem, calc(0.21rem + 0.09vw), 0.31rem) | 4px → 5px |
.pb-fluid-2 | clamp(0.5rem, calc(0.43rem + 0.18vw), 0.63rem) | 8px → 10px |
.pb-fluid-3 | clamp(0.75rem, calc(0.64rem + 0.27vw), 0.94rem) | 12px → 15px |
.pb-fluid-4 | clamp(1rem, calc(0.85rem + 0.37vw), 1.25rem) | 16px → 20px |
.pb-fluid-6 | clamp(1.5rem, calc(1.28rem + 0.56vw), 1.88rem) | 24px → 30px |
.pb-fluid-8 | clamp(2rem, calc(1.71rem + 0.74vw), 2.5rem) | 32px → 40px |
Fluid Padding Horizontal/Vertical
Fluid Padding Horizontal
| Class | Clamp Expression | Mobile → Desktop |
|---|---|---|
.px-fluid-2 | clamp(0.5rem, calc(0.43rem + 0.18vw), 0.63rem) | 8px → 10px |
.px-fluid-3 | clamp(0.75rem, calc(0.64rem + 0.27vw), 0.94rem) | 12px → 15px |
.px-fluid-4 | clamp(1rem, calc(0.85rem + 0.37vw), 1.25rem) | 16px → 20px |
.px-fluid-6 | clamp(1.5rem, calc(1.28rem + 0.56vw), 1.88rem) | 24px → 30px |
.px-fluid-8 | clamp(2rem, calc(1.71rem + 0.74vw), 2.5rem) | 32px → 40px |
Fluid Padding Vertical
| Class | Clamp Expression | Mobile → Desktop |
|---|---|---|
.py-fluid-2 | clamp(0.5rem, calc(0.43rem + 0.18vw), 0.63rem) | 8px → 10px |
.py-fluid-3 | clamp(0.75rem, calc(0.64rem + 0.27vw), 0.94rem) | 12px → 15px |
.py-fluid-4 | clamp(1rem, calc(0.85rem + 0.37vw), 1.25rem) | 16px → 20px |
.py-fluid-6 | clamp(1.5rem, calc(1.28rem + 0.56vw), 1.88rem) | 24px → 30px |
.py-fluid-8 | clamp(2rem, calc(1.71rem + 0.74vw), 2.5rem) | 32px → 40px |
Fluid Padding Examples
Common Padding Patterns
Card with Consistent Padding
Form Input Padding
Navigation with Padding
Best Practices
1
Use the 4px Scale
Always use the predefined spacing scale (1, 2, 3, 4, 6, 8, 12) for consistency.
2
Consistent Internal Spacing
Use consistent padding values within components for better visual harmony.
3
Use Shorthand When Possible
Use
.px-* and .py-* utilities when left/right or top/bottom values are the same.4
Consider Content Density
Adjust padding based on content density and user experience needs.
Common Mistakes
- Don’t mix different spacing scales inconsistently
- Don’t forget to consider mobile padding needs
- Don’t use padding where margin would be more appropriate
- Don’t over-pad small elements (keep proportions in mind)

