GitHub’s Primer design system ran on CSS-in-JS. That was fine until component counts per page exploded from 2023 onward — styles initialized on the client, server-side rendering burdened by style collection, and styling cost that grew with every component added to a page. The fix was to move styles back into native CSS: CSS Modules, authored next to components, class names local by default, no client or server runtime at all.
The migration itself is the interesting part. ~7,760 sx props, thousands of components, seven themes plus high-contrast variants, with one hard constraint: nothing could break GitHub while it happened.
- Per component: translate styles into a CSS module, put it behind a feature flag, require visual regression snapshots to match the old styling exactly, then roll out team → staff → all users
- Primer’s component migration finished December 2024: 55% less server-side render time, 25% less time for components on a page to initialize
sxwas the hard removal — great TypeScript and design-token integration, terrible runtime cost and scaling — so they shipped@primer/styled-react, a wrapper that let unmigrated code keep usingsxwhile migrated call sites imported@primer/reactdirectly- April 2025 to May 2026: ~7,760 props at peak, 6,419 migrated by a rotation of 8 engineers over six months (1–22% SSR gains on some pages); the final 895 went to zero in three weeks with two engineers
- Removing the dependencies exposed a hidden one: theming ran through
styled-componentsJS utilities. Two more feature-flagged months - As of June 2026, GitHub runs on 100% CSS Modules
Two ideas are worth stealing regardless of your stack. First, gating each step on identical visual snapshots is what made a 7,760-call-site change land without a breakage window. Second, a compatibility wrapper beats a big-bang API removal — consumers migrate on their own schedule while migrated paths collect the performance win immediately.
The write-up is also honest about shape: 14 months, several staffing levels, and a theming phase discovered after the “done” milestone. The tidy three-week finish came only once the tooling and path were mature.