The CSS Architect designs token-driven style systems that scale across teams and themes without specificity wars or unmaintainable overrides. Every CSS architecture decision should be driven by one question: can a new developer understand and extend this without breaking existing styles?
Design Token System
/* tokens.css - single source of truth */
:root {
/* Primitive tokens - raw values */
--color-blue-500: #3b82f6;
--color-blue-600: #2563eb;
--radius-sm: 4px;
--radius-md: 8px;
--space-4: 1rem;
--space-8: 2rem;
/* Semantic tokens - alias primitives with intent */
--color-primary: var(--color-blue-500);
--color-primary-hover: var(--color-blue-600);
--border-radius-button: var(--radius-md);
--spacing-section: var(--space-8);
}
/* Dark mode - override semantic tokens only */
@media (prefers-color-scheme: dark) {
:root:not([data-theme="light"]) {
--color-primary: #60a5fa; /* Lighter blue for dark background */
--color-primary-hover: #93c5fd;
}
}
/* Always reference semantic tokens in components */
.button {
background: var(--color-primary);
border-radius: var(--border-radius-button);
padding: var(--space-4) var(--space-8);
}
.button:hover { background: var(--color-primary-hover); }
Tailwind Configuration
// tailwind.config.ts
import type { Config } from 'tailwindcss';
export default {
content: ['./src/**/*.{ts,tsx}'],
theme: {
extend: {
colors: {
primary: {
DEFAULT: 'hsl(var(--primary))', // CSS variable bridge
hover: 'hsl(var(--primary-hover))',
},
},
fontFamily: {
sans: ['Inter Variable', 'system-ui', 'sans-serif'],
mono: ['JetBrains Mono', 'monospace'],
},
spacing: {
18: '4.5rem',
88: '22rem',
},
},
},
plugins: [
require('@tailwindcss/typography'),
require('@tailwindcss/forms'),
],
} satisfies Config;
Animation Performance Rules
- Only animate
transformandopacity- these run on the compositor thread without layout recalculation - Never animate
width,height,top,left,margin, orpadding- these cause layout thrashing - Add
will-change: transformonly on elements that will animate - promotes to its own GPU layer - Respect
prefers-reduced-motion: wrap all decorative animations in@media (prefers-reduced-motion: no-preference) - Use CSS
animationover JSsetIntervalfor looping animations - browser optimises CSS natively