Overview
Control spacing around and inside elements using our spacing utilities. All spacing utilities follow a consistent 4px scale for predictable, maintainable layouts. Choose between static utilities for precise control or fluid utilities that scale smoothly across viewport sizes.Margin
Control external spacing with
.m-*, .mt-*, .mb-*, and fluid variantsPadding
Control internal spacing with
.p-*, .px-*, .py-*, and fluid variantsGap
Control spacing between flex items with
.gap-* and fluid variantsSpacing Scale
All spacing 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 |
Quick Start
Basic Spacing
Fluid Spacing
Spacing Utilities Reference
Margin Utilities
- All sides:
.m-0,.m-1,.m-2,.m-3,.m-4,.m-6,.m-8,.m-12,.m-auto - Vertical:
.mt-*,.mb-*(0, 1, 2, 3, 4, 6, 8, 12) - Horizontal:
.ml-auto,.mr-auto - Fluid:
.m-fluid-*,.mt-fluid-*,.mb-fluid-*(1, 2, 3, 4, 6, 8, 12)
Padding Utilities
- All sides:
.p-0,.p-1,.p-2,.p-3,.p-4,.p-6,.p-8,.p-12 - Vertical:
.pt-*,.pb-*(0, 1, 2, 3, 4, 6, 8) - Horizontal:
.px-*(2, 3, 4, 6, 8) - Vertical:
.py-*(2, 3, 4, 6, 8) - Fluid:
.p-fluid-*,.pt-fluid-*,.pb-fluid-*,.px-fluid-*,.py-fluid-*
Gap Utilities
- Static:
.gap-1through.gap-24(4px to 96px) - Fluid:
.gap-fluid-1through.gap-fluid-24(scales from mobile to desktop)
Fluid spacing utilities use CSS
clamp() to scale smoothly between mobile and desktop viewport sizes, providing responsive spacing without media queries.Common Spacing Patterns
Card Layout
Form Layout
Section Layout
Best Practices
1
Use the 4px Scale
Always use the predefined spacing scale (1, 2, 3, 4, 6, 8, 12) for consistency.
2
Maintain Vertical Rhythm
Use consistent spacing between related elements for better visual flow.
3
Group Related Elements
Use smaller gaps within groups and larger gaps between groups.
4
Use Gap for Flex Items
Use gap utilities instead of margin for spacing between flex items.
5
Consider Responsive Design
Use fluid spacing utilities for content that needs to scale smoothly across breakpoints.
Spacing Hierarchy
Spacing Hierarchy
- Micro spacing (1-2): Fine adjustments, icon spacing
- Small spacing (3-4): Element internal spacing, form fields
- Medium spacing (6): Section internal spacing, card padding
- Large spacing (8-12): Section spacing, major layout divisions

