Styling Linear for the future with StyleX
Linear migrated its React apps from styled-components to Meta's StyleX over more than 1,000 PRs. It moved style generation to build time and made styling contracts between components explicit and enforced. The work combined a deterministic codemod, narrowly scoped coding agents and manual review, starting with leaf components while both systems coexisted. Oxlint rules and a type-aware cross-file checker enforce `sx` prop propagation, merge precedence and design tokens, with CSS Modules kept as an escape hatch. Runtime-generated LCH themes were kept by injecting StyleX's hashed variable names per ThemeProvider, and removing runtime style injection cut main-thread CPU work by roughly 20–35% on view-heavy pages.
Related posts
- StyleX: A Styling Library for CSS at Scale
Meta Engineering mediumAdeptStyleX is Meta's build-time CSS-in-JS compiler that extracts style objects into collision-free atomic CSS, replacing the earlier cx system and cutting CSS size by 80% across Facebook, Instagram, WhatsApp and others. A Babel plugin hashes each property-value pair into a class, caches per file, and uses deterministic hashes for defineVars/defineConsts so it never reads imported modules. Merging is predictable (last style wins), and shorthand/longhand, pseudo-class and media-query conflicts are resolved by computing numeric priorities enforced via @layer or a polyfill. Constraints such as banning global and descendant selectors prevent styling at a distance, while stylex.when, dynamic styles via CSS variables, and theming APIs keep it expressive.
- Improving site performance by shipping more CSS
GitHub Engineering mediumAdeptGitHub migrated its Primer Design System and the github.com codebase from styled-components CSS-in-JS to CSS Modules, removing runtime styling costs on client and server. Primer components moved first, each behind a feature flag and checked against visual regression snapshots, which cut server-side render time by 55% and component initialization by 25%. A wrapper package, @primer/styled-react, kept the legacy `sx` prop working during the transition. About 7,760 `sx` props were then migrated with a VS Code plugin, codemods and later Copilot coding agents, followed by decoupling theming, and dotcom reached 100% CSS Modules in June 2026 without breakage.
- Hydrogen & Tailwind: The Perfect Match for Building Beautiful Storefronts
Shopify Engineering mediumAdeptTailwind's utility classes ship as the default styling option in Shopify's React-based Hydrogen storefront framework, and the case for them rests on componentization: styles live in reusable React components rather than semantically named classes like BEM-style product-card__title, so layouts can be copied or extracted (e.g. ProductCard to BlogCard) without renaming or duplicating CSS. Further arguments include enforced spacing and color constraints for visual consistency, copy-paste composability from libraries like Tailwind UI, easier team collaboration, and not having to name things. The tradeoff is a real learning curve that still requires CSS fundamentals, eased by good docs and the VSCode extension.
- Why We Ripped Twin out of 400+ Components
Railway mediumAdeptRailway replaced twin.macro with vanilla Tailwind across 400+ React components, which removed the last dependency on Babel and let the monorepo move fully to SWC. Dev cold starts dropped from ~35s to ~1.5s, a full build from 220s to 42s, and CI from 4-6 to 2-4 minutes. The migration took ~30 PRs with a codemod and custom helpers. Nested selectors moved to Tailwind-processed CSS files, theme() calls became CSS variables, and Twin's inline-style precedence and automatic merging were handled by migrating pages first and core components last, using `!` overrides and tailwind-merge.
- The New York Times Games’ Path to Dark Mode
NYT Open easyNoviceShipping Dark Mode for New York Times Games turned into paying down years of design debt, because eight games each had their own hex colors, fonts and component styles. The team limited scope to the Games app and launched Dark Mode game by game. They consolidated hex values into primitive and semantic design tokens across three libraries (Games Home, Games Brand, Gameplay), and tuned colors such as Connections' beige tiles so play feels the same in both modes. Implementation uses CSS variables in a React/TypeScript design system with a Provider and hooks, enabling per-game, per-surface rollout. Dark Mode users go on to play and complete more puzzles.