34.Legacy CSS to design tokens
Overview
Extract the current live site to capture what actually shipped. Use that as ground truth to generate CSS custom properties and replace scattered hardcoded values across the codebase.
Legacy CSS codebases typically have no token system: colors are hardcoded in hundreds of places, spacing is arbitrary, and there is no single source of truth for any visual property. Extract the live site to capture the actual token values that shipped, then use that as ground truth to generate a CSS custom properties file (:root { ... }) and systematically replace hardcoded values across the codebase with var() references. This migration can be done incrementally: generate the token file first, then refactor one component or file at a time.
Extract live site
CSS custom properties file + refactored stylesheets using var() references.
More in Code & Tokens
Browse all
All recipes →