Design System Implementation: Colors, Fonts & Spacing
Introduction
This article details the implementation of a comprehensive design system for the Anchorpipe documentation, focusing on colors, typography, and spacing. The goal is to provide a consistent and professional user experience, ensuring developers can focus on content without visual distractions. This design system establishes a cohesive visual language using HSL-based colors, a defined typography scale, spacing tokens, border radius, and animation guidelines.
Persona
- End-user (Application end user)
Area
- docs (Documentation)
User Need / Problem Statement
As a developer viewing the documentation, I want to see a consistent, professional design system throughout the site, So that I can focus on content without visual inconsistencies distracting me.
Context: The current documentation lacks a comprehensive design system and uses a basic blue color scheme (#0066CC). This article outlines the implementation of a complete design system foundation, including an HSL-based color system, typography scale, spacing tokens, border radius, and animation guidelines to establish a cohesive visual language.
Color System Implementation
Color system implementation is the cornerstone of a visually appealing and consistent design. Our new color system uses a red-based palette (#D41818) with HSL (Hue, Saturation, Lightness) format for better theming and adaptability. All color variables are defined in HSL to facilitate easy adjustments for theming purposes, especially concerning light and dark mode variants. The color palette includes primary, secondary, muted, accent, and destructive colors to cover various UI needs. Light and dark mode variants are configured to ensure readability and visual comfort in different environments. Ensuring the accessibility of our color choices is critical, so all color contrast ratios meet WCAG AA standards, with a minimum of 4.5:1 for normal text and 3:1 for large text. This ensures that users with visual impairments can easily read and interact with the documentation. The color system not only enhances the aesthetic appeal but also ensures usability and accessibility across different user preferences and needs. This foundational step is crucial for creating a unified and professional documentation experience. Furthermore, having a well-defined color system simplifies future design updates and expansions, allowing for consistent branding and visual communication throughout the Anchorpipe ecosystem. By adopting HSL, we gain the flexibility to adjust the hue, saturation, or lightness independently, which is particularly useful for creating color variations and themes. In essence, a robust color system is more than just aesthetics; it's about creating an inclusive, usable, and maintainable product.
Implementation Details:
- Complete color palette implemented (primary, secondary, muted, accent, destructive).
- Surface layers defined (surface-1, surface-2, surface-3).
- Red spectrum colors defined (red-light, red-base, red-dark, red-glow, red-subtle).
- All variables work in both light and dark modes.
- CSS variables are properly scoped and accessible.
Light Mode:
:root {
/* Core Colors */
--background: 0 0% 100%; /* #FFFFFF - Pure white */
--foreground: 0 0% 5%; /* #0D0D0D - Near black */
/* Surface Layers */
--card: 0 0% 98%; /* #FAFAFA */
--surface-1: 0 0% 98%; /* #FAFAFA */
--surface-2: 0 0% 96%; /* #F5F5F5 */
--surface-3: 0 0% 92%; /* #EBEBEB */
/* Primary (Red) */
--primary: 0 85% 45%; /* #D41818 - Core red */
--primary-foreground: 0 0% 100%; /* White text on primary */
/* Red Spectrum */
--red-light: 0 85% 60%; /* #E85C5C */
--red-base: 0 85% 45%; /* #D41818 */
--red-dark: 0 70% 35%; /* #982020 */
--red-glow: 0 100% 50%; /* #FF0000 */
--red-subtle: 0 30% 90%; /* #F2E3E3 */
/* Secondary & Muted */
--secondary: 0 0% 96%; /* #F5F5F5 */
--secondary-foreground: 0 0% 10%; /* #1A1A1A */
--muted: 0 0% 94%; /* #F0F0F0 */
--muted-foreground: 0 0% 40%; /* #666666 */
/* Borders & Interactive */
--border: 0 0% 88%; /* #E0E0E0 */
--input: 0 0% 88%;
--ring: 0 85% 45%; /* Focus ring = primary */
/* Accent (Alternative Red) */
--accent: 0 70% 45%; /* #C22929 */
--accent-foreground: 0 0% 100%;
/* Semantic */
--destructive: 0 84% 50%; /* #EC2020 */
--destructive-foreground: 0 0% 100%;
/* Design Tokens */
--radius: 0.75rem; /* 12px base radius */
}
Dark Mode:
.dark, [data-theme='dark'] {
--background: 0 0% 2%; /* #050505 - Near black */
--foreground: 0 0% 98%; /* #FAFAFA - Near white */
/* Surface Layers - Elevated darkness */
--card: 0 0% 5%; /* #0D0D0D */
--surface-1: 0 0% 4%; /* #0A0A0A */
--surface-2: 0 0% 6%; /* #0F0F0F */
--surface-3: 0 0% 10%; /* #1A1A1A */
/* Primary - Brighter for dark backgrounds */
--primary: 0 85% 55%; /* #E83C3C */
--primary-foreground: 0 0% 100%;
/* Red Spectrum - Adjusted for dark mode */
--red-light: 0 85% 65%; /* #EE7070 */
--red-base: 0 85% 55%; /* #E83C3C */
--red-dark: 0 70% 40%; /* #AD2626 */
--red-glow: 0 100% 50%; /* #FF0000 */
--red-subtle: 0 50% 20%; /* #4D1A1A */
/* Secondary & Muted */
--secondary: 0 0% 8%; /* #141414 */
--secondary-foreground: 0 0% 98%;
--muted: 0 0% 12%; /* #1F1F1F */
--muted-foreground: 0 0% 50%; /* #808080 */
/* Borders */
--border: 0 0% 12%; /* #1F1F1F */
--input: 0 0% 12%;
--ring: 0 85% 55%;
}
Typography System Implementation
Typography system implementation is critical for ensuring readability and consistency in our documentation. The typography system uses two primary font families: Inter (sans-serif) and JetBrains Mono (monospace). Inter is used for general text to ensure readability, while JetBrains Mono is used for code snippets and technical elements, providing a clear distinction. We've defined a comprehensive type scale, including styles for display, headings (h1-h6), body text, small text, extra-small text, and monospace text. Each type style is defined with specific font weights and line heights to match the design system, ensuring visual harmony across all pages. Maintaining consistent typography across all pages helps create a professional and cohesive look, which is essential for user experience. Font weights and line heights are carefully chosen to optimize readability and visual hierarchy, making it easier for users to scan and understand the content. The implementation of this typography system enhances the overall aesthetic appeal and user-friendliness of the documentation. By carefully selecting and defining these elements, we create a consistent and professional reading experience for our users. This well-structured typography system not only improves readability but also contributes to the overall brand identity and user trust in the documentation.
Implementation Details:
- Font families are Inter (sans) and JetBrains Mono (mono).
- Type scale is properly defined (display, h1-h6, body, small, xs, mono).
- Font weights and line heights match the design system.
- Typography is consistent across all pages.
/* Font Imports */
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600&family=Inter:wght@400;500;600;700;800&display=swap');
/* Font Families */
--font-sans: 'Inter', system-ui, -apple-system, sans-serif;
--font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
/* Type Scale */
/* Display: 4.5rem, 700-800 weight, 1.1 line height - Hero headlines */
/* h1: 3rem, 700 weight, 1.2 line height - Page titles */
/* h2: 2rem, 600-700 weight, 1.25 line height - Section headings */
/* h3: 1.5rem, 600 weight, 1.3 line height - Subsection headings */
/* h4: 1.25rem, 600 weight, 1.4 line height - Card titles */
/* body: 1rem, 400 weight, 1.7 line height - Paragraph text */
/* body-lg: 1.125rem, 400 weight, 1.6 line height - Lead paragraphs */
/* small: 0.875rem, 400-500 weight, 1.5 line height - Captions, meta */
/* xs: 0.75rem, 500 weight, 1.4 line height - Labels, badges */
/* mono: 0.875rem, 400 weight, 1.6 line height - Code, technical */
Spacing System Implementation
Spacing system implementation is crucial for creating a visually structured and easily navigable interface. The spacing system uses a 4px base unit, ensuring consistency and scalability across all components and pages. We've defined specific spacing tokens (0.5, 1, 1.5, 2, 3, 4, 5, 6, 8, 10, 12, 16, 20, 24) to cover various spacing needs, from tight inline spacing to large section padding. These spacing tokens are consistently applied to maintain visual hierarchy and balance, making the content more accessible and user-friendly. Consistent spacing helps guide the userβs eye and create a clear path through the information. This structured approach not only improves the aesthetic appeal but also enhances usability by preventing content from feeling cluttered or overwhelming. By adhering to a defined spacing system, we ensure that the documentation is both visually pleasing and easy to navigate. This is vital for maintaining user engagement and ensuring that developers can quickly find the information they need. The 4px base unit system offers flexibility while maintaining a predictable and harmonious layout, contributing to a more professional and polished user experience. In essence, a well-defined spacing system is more than just about aesthetics; it is about creating a user-centered design that prioritizes clarity and ease of use.
Implementation Details:
- Spacing uses the 4px base unit system.
- Spacing tokens are consistently applied.
- Visual hierarchy is clear through spacing.
/* Base unit: 4px (0.25rem) */
/* Token 0.5: 0.125rem (2px) - Hairline spacing */
/* Token 1: 0.25rem (4px) - Tight inline spacing */
/* Token 1.5: 0.375rem (6px) - Icon gaps */
/* Token 2: 0.5rem (8px) - Button padding, tight gaps */
/* Token 3: 0.75rem (12px) - Card padding (sm) */
/* Token 4: 1rem (16px) - Standard gaps */
/* Token 5: 1.25rem (20px) - Medium padding */
/* Token 6: 1.5rem (24px) - Section gaps */
/* Token 8: 2rem (32px) - Card padding, large gaps */
/* Token 10: 2.5rem (40px) - Section padding */
/* Token 12: 3rem (48px) - Major section breaks */
/* Token 16: 4rem (64px) - Page sections */
/* Token 20: 5rem (80px) - Hero padding */
/* Token 24: 6rem (96px) - Large section padding */
Additional Design System Elements
Border Radius System:
/* sm: 0.5rem - Small buttons, badges */
/* md: 0.625rem - Inputs, small cards */
/* lg: 0.75rem (--radius) - Default cards, buttons */
/* xl: 1rem - Large cards, modals */
/* 2xl: 1.25rem - Feature cards */
/* 3xl: 1.5rem - Hero elements */
/* full: 9999px - Pills, avatars */
Animation Guidelines:
/* Timing Functions */
--ease-smooth: cubic-bezier(0.4, 0, 0.2, 1); /* Standard easing */
--ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1); /* Playful bounce */
--ease-out: cubic-bezier(0, 0, 0.2, 1); /* Deceleration */
/* Duration Scale */
/* 150ms - Micro-interactions (hover states) */
/* 200ms - Button clicks, toggles */
/* 300ms - Standard transitions */
/* 500ms - Page element animations */
/* 800ms - Complex entrance animations */
/* Keyframe Animations */
@keyframes fade-in-up {
from {
opacity: 0;
transform: translateY(40px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
@keyframes fade-in {
from { opacity: 0; }
to { opacity: 1; }
}
@keyframes scale-in {
from {
opacity: 0;
transform: scale(0.9);
}
to {
opacity: 1;
transform: scale(1);
}
}
@keyframes float {
0%, 100% { transform: translateY(0px) rotate(0deg); }
50% { transform: translateY(-20px) rotate(2deg); }
}
@keyframes shimmer {
0% { background-position: -200% 0; }
100% { background-position: 200% 0; }
}
@keyframes glow-pulse {
0%, 100% {
opacity: 0.6;
transform: scale(1);
}
50% {
opacity: 1;
transform: scale(1.02);
}
}
Non-Functional Requirements
- Accessibility: WCAG 2.2 AA compliance considered
- Performance: Meets performance budget (bundle <100KB gzipped, Core Web Vitals 'Good')
- Security: Security review completed (input validation, CSP, CSRF/origin checks, rate limiting)
- Usability: User experience reviewed and validated
- Testability: Unit and integration tests included
- Documentation: User-facing documentation updated
- Observability: Logging and monitoring instrumented
- Internationalization: i18n/l10n considered if applicable
Test Scenarios
Manual Test Scenarios:
- View color scheme β Verify red-based palette
- Toggle dark mode β Verify colors work in both modes
- Check contrast β Verify WCAG AA compliance using contrast checker
- View typography β Verify Inter and JetBrains Mono fonts load correctly
- Check spacing β Verify consistent spacing tokens
- Test animations β Verify keyframes work correctly
- Check reduced motion β Verify animations respect
prefers-reduced-motion
Automated Tests:
- Build succeeds without CSS errors
- Color contrast validation (manual or tool)
- Font loading verification
- CSS variables accessible in both light and dark modes
Conclusion
Implementing a comprehensive design system is a critical step in creating a consistent, professional, and user-friendly documentation experience. By focusing on colors, typography, and spacing, we ensure that developers can focus on the content without visual distractions. This foundation sets the stage for future design work and component development, ensuring that the Anchorpipe documentation remains accessible, usable, and visually appealing. For more information on design systems and best practices, visit Material Design.