Overview
Use gap utilities to control the spacing between flex items. Gap is the modern way to add spacing between flex items without using margin utilities. These utilities work with a consistent 4px scale and include both static and fluid variants for responsive designs.Spacing Scale
All gap utilities follow a consistent 4px scale for predictable layouts.Spacing Scale
| 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 |
Static Gap Utilities
Control spacing between flex items with static gap utilities.Gap Properties
.gap-1 | 4px | gap: 4px; | Small gap |
.gap-2 | 8px | gap: 8px; | Small gap |
.gap-3 | 12px | gap: 12px; | Medium gap |
.gap-4 | 16px | gap: 16px; | Standard gap |
.gap-6 | 24px | gap: 24px; | Large gap |
.gap-8 | 32px | gap: 32px; | Extra large gap |
.gap-10 | 40px | gap: 40px; | Extra large gap |
.gap-12 | 48px | gap: 48px; | Section gap |
.gap-14 | 56px | gap: 56px; | Large section gap |
.gap-16 | 64px | gap: 64px; | Extra large section gap |
.gap-18 | 72px | gap: 72px; | Very large gap |
.gap-20 | 80px | gap: 80px; | Huge gap |
.gap-22 | 88px | gap: 88px; | Extra huge gap |
.gap-24 | 96px | gap: 96px; | Maximum gap |
Examples
Fluid Gap Utilities
Fluid gap utilities useclamp() to scale smoothly between mobile and desktop sizes, perfect for responsive layouts.
Fluid Gap Properties
| Class | Clamp Expression | Mobile → Desktop |
|---|---|---|
.gap-fluid-1 | clamp(0.25rem, calc(0.21rem + 0.09vw), 0.31rem) | 4px → 5px |
.gap-fluid-2 | clamp(0.5rem, calc(0.43rem + 0.18vw), 0.63rem) | 8px → 10px |
.gap-fluid-3 | clamp(0.75rem, calc(0.64rem + 0.27vw), 0.94rem) | 12px → 15px |
.gap-fluid-4 | clamp(1rem, calc(0.85rem + 0.37vw), 1.25rem) | 16px → 20px |
.gap-fluid-6 | clamp(1.5rem, calc(1.28rem + 0.56vw), 1.88rem) | 24px → 30px |
.gap-fluid-8 | clamp(2rem, calc(1.71rem + 0.74vw), 2.5rem) | 32px → 40px |
.gap-fluid-10 | clamp(2.5rem, calc(2.14rem + 0.93vw), 3.13rem) | 40px → 50px |
.gap-fluid-12 | clamp(3rem, calc(2.56rem + 1.1vw), 3.75rem) | 48px → 60px |
.gap-fluid-14 | clamp(3.5rem, calc(2.99rem + 1.29vw), 4.38rem) | 56px → 70px |
.gap-fluid-16 | clamp(4rem, calc(3.42rem + 1.48vw), 5rem) | 64px → 80px |
.gap-fluid-18 | clamp(4.5rem, calc(3.84rem + 1.67vw), 5.63rem) | 72px → 90px |
.gap-fluid-20 | clamp(5rem, calc(4.27rem + 1.85vw), 6.25rem) | 80px → 100px |
.gap-fluid-22 | clamp(5.5rem, calc(4.7rem + 2.04vw), 6.88rem) | 88px → 110px |
.gap-fluid-24 | clamp(6rem, calc(5.13rem + 2.22vw), 7.5rem) | 96px → 120px |
Fluid Gap Examples
Common Gap Patterns
Navigation with Gap
Card Grid with Gap
Button Group with Gap
Form Fields with Gap
Best Practices
1
Use Gap for Flex Items
Always use gap utilities instead of margin for spacing between flex items.
2
Consistent Gap Values
Use consistent gap values within the same component or section.
3
Use Fluid for Responsive
Use fluid gap utilities for layouts that need to scale smoothly across breakpoints.
4
Match Gap to Content
Choose gap values that match the visual weight and importance of the content.
Gap vs Margin
When to Use Gap
- Spacing between flex items
- Grid layouts
- Button groups
- Navigation items
- Card grids
When to Use Margin
- Spacing between sections
- Pushing elements away from container edges
- Centering elements (with auto)
- Creating space outside elements
Gap is applied to the flex container and automatically spaces all direct children. This is more efficient and predictable than using margin on individual items.
Common Mistakes
- Don’t use margin for spacing between flex items (use gap instead)
- Don’t mix gap and margin inconsistently
- Don’t forget gap works on both row and column flex directions
- Don’t use gap on non-flex containers (it won’t have any effect)

