This document outlines the unified spacing system implemented to ensure consistent margins, padding, and layouts throughout the website.
The following custom spacing tokens are defined in tailwind.config.ts:
section-sm: 48px (3rem) - Small section spacingsection-md: 64px (4rem) - Medium section spacingsection-lg: 80px (5rem) - Large section spacingsection-xl: 96px (6rem) - Extra large section spacing
content-sm: 16px (1rem) - Small content spacingcontent-md: 24px (1.5rem) - Medium content spacingcontent-lg: 32px (2rem) - Large content spacing
container-padding: 24px (1.5rem) - Standard container padding
<main className="flex flex-col min-h-[100dvh] py-section-md">
<section className="mb-section-lg">
<div className="space-y-content-lg">
{/* Section content */}
</div>
</section>
</main>The global container is applied in layout.tsx:
<div className="max-w-2xl mx-auto px-container-padding">
{children}
</div>- Between Sections: Use
mb-section-lgon all sections except the last one - Section Content: Use
space-y-content-lgfor main section content areas - Sub-content: Use
space-y-content-mdfor grouped content - Text Content: Use
space-y-content-smfor paragraph spacing
- Base padding:
p-content-md(handled by Card component) - Header spacing:
space-y-1.5 - Content spacing: Uses default padding from Card components
- Paragraph spacing:
space-y-content-sm - Section titles: Handled by section spacing
Additional utility classes are available in globals.css:
.section-spacing- Appliesmb-section-lg.content-spacing-sm/md/lg- Applies corresponding space-y classes.page-container- Standard page container with max-width and padding.prose-spacing- Consistent spacing for text content
// Inconsistent spacing
<main className="space-y-10">
<section className="py-12">
<div className="space-y-8">
<p className="mt-4">Content</p>
</div>
</section>
</main>// Consistent spacing with design tokens
<main className="py-section-md">
<section className="mb-section-lg">
<div className="space-y-content-lg">
<div className="space-y-content-sm">
<p>Content</p>
</div>
</div>
</section>
</main>- Consistency: All spacing follows a unified scale
- Maintainability: Easy to adjust spacing globally by modifying tokens
- Predictability: Developers know which spacing to use in different contexts
- Responsive: Spacing tokens can be extended with responsive variants if needed
- Semantic: Spacing names clearly indicate their intended use
- Always use spacing tokens instead of arbitrary values
- Follow the section structure outlined above
- Use semantic spacing (section vs content vs container)
- Avoid adding extra margins/padding that conflict with the system
- Test spacing on different screen sizes to ensure consistency