Spacing

Davis uses a 4px base grid powered by Tailwind's default spacing scale. All spacing values are multiples of 4px (0.25rem), ensuring consistent rhythm across the entire interface.


Visual Scale

0.5
0.125rem (2px)
1
0.25rem (4px)
1.5
0.375rem (6px)
2
0.5rem (8px)
3
0.75rem (12px)
4
1rem (16px)
5
1.25rem (20px)
6
1.5rem (24px)
8
2rem (32px)
10
2.5rem (40px)
12
3rem (48px)
16
4rem (64px)
20
5rem (80px)
24
6rem (96px)

Spacing Guide

UseTailwindrempx
inline tight0.50.1252
minimum10.254
compact padding1.50.3756
small padding20.58
component padding30.7512
card padding4116
section spacing61.524
large section8232
page section gap12348
page gutter16464
hero spacing20580
max section24696

Usage Recommendations

Component-level spacing

ContextTailwind classValue
Tight inline spacing (icons, badges)gap-1 / p-14px
Compact padding (small buttons, tags)px-2 py-18px / 4px
Default button paddingpx-6 py-224px / 8px
Input paddingpx-3 py-212px / 8px
Card padding (default)p-624px
Card padding (compact)p-416px

Form spacing

ContextTailwind classValue
Gap between label and inputgap-1.56px
Gap between form fieldsspace-y-416px
Gap between form sectionsspace-y-832px
Form action buttons gapgap-312px

Page-level spacing

ContextTailwind classValue
Content max-widthmax-w-4xl896px
Wide content max-widthmax-w-6xl1152px
Page horizontal paddingpx-4 sm:px-6 lg:px-816-32px
Section vertical spacingpy-8 sm:py-1232-48px
Page top/bottom marginpy-832px

The 4px Grid

Every spacing value in the system is a multiple of 4px:

Why 4px? A 4px grid provides fine-grained control while maintaining visual consistency. It's small enough for compact UI elements but large enough to create perceptible spacing differences between adjacent values.


Tips

  • Prefer gap over margin — Use gap-* on flex/grid containers rather than margin on children. It's cleaner and avoids margin collapse issues.
  • Use space-y-* for stacks — Vertical lists of items benefit from space-y-4 or space-y-6.
  • Stay on the grid — Avoid arbitrary values like p-[7px]. If the spacing doesn't feel right, move to the next grid value up or down.
  • Scale with breakpoints — Increase spacing at larger breakpoints: gap-4 md:gap-6 lg:gap-8.