Episode 1 — Fundamentals / 1.6 — CSS Core Fundamentals
1.6.h — Design Systems
In one sentence: A design system is a shared vocabulary of constraints, patterns, and components that ensures visual and functional consistency across a product — CSS is the enforcement layer, custom properties and tokens are the bridge between design and code.
Navigation: ← 1.6.g — CSS Variables · 1.6.i — Design Tokens →
1. What is a design system?
A design system is more than a component library. It typically includes:
| Layer | What it contains |
|---|---|
| Design principles | Brand values, tone, accessibility commitments |
| Design tokens | Primitive values: colors, spacing, typography, radii, shadows |
| Component patterns | Buttons, cards, modals, forms — with states, variants, and a11y |
| Layout conventions | Grid system, container widths, spacing rhythm |
| Documentation | Usage guidelines, do/don't examples, code snippets |
Goal: any designer or developer can build a new page that feels native to the product without inventing new styles.
2. Why design systems matter for CSS
Without a system, CSS codebases accumulate:
- 200 shades of gray — each developer picks slightly different values
- Inconsistent spacing —
12pxhere,15pxthere,1.2remsomewhere else - Specificity wars — one-off overrides pile up
- Brittle components — styling tied to page structure, not reusable
A design system constrains choices to a finite palette of tokens — your CSS becomes predictable, reviewable, and maintainable.
3. Anatomy of a design system (CSS perspective)
Color system
:root {
/* Primitives */
--blue-500: #2563eb;
--blue-600: #1d4ed8;
--gray-100: #f1f5f9;
--gray-900: #0f172a;
/* Semantic aliases */
--color-primary: var(--blue-500);
--color-primary-hover: var(--blue-600);
--color-bg: var(--gray-100);
--color-text: var(--gray-900);
}
Primitives are the raw palette; semantic tokens map them to roles (primary, danger, surface). Components use semantic tokens — when the brand changes, you update the mapping, not every component.
Typography scale
:root {
--font-sans: system-ui, -apple-system, sans-serif;
--font-mono: ui-monospace, 'Cascadia Code', monospace;
--text-xs: 0.75rem; /* 12px */
--text-sm: 0.875rem; /* 14px */
--text-base: 1rem; /* 16px */
--text-lg: 1.125rem; /* 18px */
--text-xl: 1.25rem; /* 20px */
--text-2xl: 1.5rem; /* 24px */
--text-3xl: 1.875rem; /* 30px */
--leading-tight: 1.25;
--leading-normal: 1.5;
--leading-relaxed: 1.75;
}
Spacing scale
:root {
--space-1: 0.25rem; /* 4px */
--space-2: 0.5rem; /* 8px */
--space-3: 0.75rem; /* 12px */
--space-4: 1rem; /* 16px */
--space-6: 1.5rem; /* 24px */
--space-8: 2rem; /* 32px */
--space-12: 3rem; /* 48px */
--space-16: 4rem; /* 64px */
}
Consistent rhythm: multiples of a base unit (4px or 8px) keep vertical and horizontal spacing harmonious.
4. Component-level patterns
A well-designed component uses system tokens, not hardcoded values:
.button {
font-family: var(--font-sans);
font-size: var(--text-sm);
font-weight: 600;
padding: var(--space-2) var(--space-4);
border-radius: var(--radius-md);
background-color: var(--color-primary);
color: var(--color-on-primary);
border: none;
cursor: pointer;
transition: background-color 150ms ease;
}
.button:hover {
background-color: var(--color-primary-hover);
}
.button:focus-visible {
outline: 2px solid var(--color-focus);
outline-offset: 2px;
}
Benefits: changing the primary color or spacing scale updates every button automatically.
5. Design system anti-patterns
| Anti-pattern | Problem |
|---|---|
| Using design system tokens + hardcoded values in the same component | Inconsistency; tokens lose their purpose |
| Too many tokens (1000+ named colors) | Decision fatigue; might as well not have a system |
No semantic layer (using --blue-500 directly in components) | Brand change requires touching every component |
| Building components in isolation without token constraints | Drift; components don't compose visually |
| Design system as "set and forget" | Systems need maintenance — evolve tokens as the product evolves |
6. Popular design systems (awareness)
| System | Organization | Notes |
|---|---|---|
| Material Design | Comprehensive spec, component libraries for multiple frameworks | |
| Ant Design | Ant Group | Enterprise-focused, React ecosystem |
| Carbon | IBM | Accessibility-first, detailed token documentation |
| Primer | GitHub | Open-source, integrates with their design tokens |
| Chakra UI | Community | React component library with token-based theming |
Study these for patterns, not to copy — your product's design system should reflect your brand and constraints.
7. Key takeaways
- A design system is principles + tokens + components + documentation.
- Tokens replace magic numbers — finite palette of colors, spacing, type.
- Components reference semantic tokens, not raw values — enables theming and brand evolution.
- Consistency reduces cognitive load for users and developers.
- Design systems are living — they evolve with the product.
Explain-It Challenge
Explain without notes:
- Why using
var(--color-primary)in components is better than hardcoding#2563eb. - The difference between a primitive token (
--blue-500) and a semantic token (--color-primary). - What problem a spacing scale (4px / 8px rhythm) solves in practice.
Navigation: ← 1.6.g — CSS Variables · 1.6.i — Design Tokens →