Thrive Design System

Foundation

Spacing

A systematic spacing scale that creates consistent rhythm, alignment, and visual harmony across layouts.

Usage

Overview

The Thrive Design System uses a purposeful spacing scale built on a base unit of 4px (0.25rem). This scale ensures consistent rhythm and alignment across all components and layouts, making interfaces feel cohesive and well-crafted.

  • Spacing tokens define the whitespace between and within UI elements.
  • Consistent spacing reduces cognitive load and creates a sense of order.
  • The scale progresses from tight (compact UIs) to generous (breathing room for content-heavy layouts).

Spacing Scale

TokenValuePixelsUse Case
--spacing-000pxNo spacing, flush elements
--spacing-4xs0.0625rem1pxHairline gaps, borders
--spacing-3xs0.125rem2pxMinimal separation
--spacing-2xs0.25rem4pxTight inline spacing
--spacing-xs0.5rem8pxCompact element gaps
--spacing-s0.75rem12pxRelated element spacing
--spacing-default1rem16pxDefault padding and gaps
--spacing-lg1.25rem20pxComfortable padding
--spacing-xl1.5rem24pxSection padding
--spacing-2xl2rem32pxGroup separation
--spacing-supra-12.5rem40pxLarge section gaps
--spacing-supra-23rem48pxPage-level spacing
--spacing-supra-34rem64pxMajor section breaks
--spacing-supra-45rem80pxHero spacing
--spacing-ultra-16rem96pxFull-page sections
--spacing-ultra-28rem128pxGenerous layout spacing
--spacing-ultra-316rem256pxMaximum spacing

Best Practices

  • Use smaller tokens (2xs-xs) for spacing within components (padding, inline gaps).
  • Use medium tokens (s-xl) for spacing between related elements.
  • Use larger tokens (2xl-supra) for spacing between sections and page-level layouts.
  • Always use spacing tokens instead of arbitrary values to maintain consistency.
  • When in doubt, use --spacing-default (16px) as your starting point.

When Not to Use

  • Don't use spacing tokens for sizing elements (width/height); use sizing tokens or Tailwind utilities instead.
  • Avoid mixing arbitrary pixel values with token-based spacing in the same context.

Usage in Code

CSS Custom Properties

.my-component {
  padding: var(--spacing-default);
  gap: var(--spacing-xs);
  margin-bottom: var(--spacing-2xl);
}

Tailwind Classes

The spacing scale maps to Tailwind utility classes:

<div class="p-4 gap-2 mb-8">
  <!-- p-4 = 16px, gap-2 = 8px, mb-8 = 32px -->
</div>
TokenTailwindExample
--spacing-2xs1p-1, gap-1, m-1
--spacing-xs2p-2, gap-2, m-2
--spacing-s3p-3, gap-3, m-3
--spacing-default4p-4, gap-4, m-4
--spacing-lg5p-5, gap-5, m-5
--spacing-xl6p-6, gap-6, m-6
--spacing-2xl8p-8, gap-8, m-8

Accessibility

  • Adequate spacing improves readability and reduces visual clutter, benefiting all users.
  • Touch targets should have at least 44px of tappable area; use spacing to ensure sufficient clearance between interactive elements.
  • Generous spacing around text improves readability for users with cognitive disabilities.