Swiss Grid System Spacing

Our spacing system is based on an 8px base unit, following Swiss grid system principles. This provides:

  • Consistent, predictable spacing across all components
  • Mathematical harmony (all values divisible by 4 and 8)
  • Generous negative space for clarity and focus
  • Scalable spacing that maintains proportions

Formula: Each spacing value = base unit (8px) × multiplier. For example, lg = 8px × 3 = 24px.

Spacing Scale

xs
0.25rem4px(0.5 units)
Extra small spacing

Common Usage:

  • • Icon padding
  • • Tight inline elements
  • • Minor adjustments
sm
0.5rem8px(1 unit)
Small spacing (1 base unit)

Common Usage:

  • • Compact element spacing
  • • List item gaps
  • • Form element spacing
md
1rem16px(2 units)
Medium spacing (2 base units)

Common Usage:

  • • Default element spacing
  • • Card padding
  • • Section gaps
lg
1.5rem24px(3 units)
Large spacing (3 base units)

Common Usage:

  • • Generous padding
  • • Component separation
  • • Subsection gaps
xl
2rem32px(4 units)
Extra large spacing (4 base units)

Common Usage:

  • • Major component spacing
  • • Section padding
  • • Layout gaps
2xl
3rem48px(6 units)
Double extra large (6 base units)

Common Usage:

  • • Large section spacing
  • • Hero section padding
  • • Major layout gaps
3xl
4rem64px(8 units)
Triple extra large (8 base units)

Common Usage:

  • • Spacious section padding
  • • Major layout divisions
  • • Hero sections
4xl
6rem96px(12 units)
Quadruple extra large (12 base units)

Common Usage:

  • • Extra spacious sections
  • • Landing page hero
  • • Maximum whitespace
5xl
8rem128px(16 units)
Quintuple extra large (16 base units)

Common Usage:

  • • Maximum section spacing
  • • Full-page layouts
  • • Exceptional whitespace

Tailwind CSS Mapping

Our spacing tokens align with Tailwind's spacing scale for seamless integration:

TokenTailwind ClassValueExample
xsp-1, m-1, gap-14pxclassName="p-1"
smp-2, m-2, gap-28pxclassName="gap-2"
mdp-4, m-4, gap-416pxclassName="p-4"
lgp-6, m-6, gap-624pxclassName="p-6"
xlp-8, m-8, gap-832pxclassName="gap-8"
2xlp-12, m-12, gap-1248pxclassName="py-12"
3xlp-16, m-16, gap-1664pxclassName="mb-16"
4xlp-24, m-24, gap-2496pxclassName="py-24"
5xlp-32, m-32, gap-32128pxclassName="py-32"

Best Practices

1. Embrace Negative Space

Swiss design emphasizes generous whitespace. Use larger spacing values (xl, 2xl, 3xl) liberally for major sections. Whitespace is not wasted space—it creates clarity and focus.

2. Consistent Vertical Rhythm

Maintain consistent spacing between elements on the same hierarchy level. For example, if one section uses mb-8, all peer sections should use the same spacing.

3. Scale Appropriately

Larger elements warrant larger spacing. Hero sections should use 3xl or 4xl padding, while compact UI elements like buttons should use sm or md spacing.

4. Avoid Arbitrary Values

Stick to the defined spacing scale. Avoid arbitrary pixel values like p-[13px]. If a spacing value doesn't exist in the scale, choose the closest one or consider if it's truly needed.

Live Examples

Compact Layout (sm spacing)

Item 1
Item 2
Item 3

Default Layout (md spacing)

Item 1
Item 2
Item 3

Spacious Layout (xl spacing)

Item 1
Item 2
Item 3