---
title: "Why We Ripped Twin out of 400+ Components"
description: "Railway 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."
url: "https://swe.quest/articles/why-we-ripped-twin-out-of-400-components-f0b99539dbfc3cb4"
canonical: "https://blog.railway.com/p/twin-macro-tailwind-migration"
source: "Railway"
published: "2023-05-04"
difficulty: "medium"
kind: "Case study"
reading_minutes: 7
tags: ["css","frontend","refactoring","build-systems","react"]
---

# Why We Ripped Twin out of 400+ Components

A post on [Railway](https://swe.quest/sources/railway.md), published 2023-05-04, 7 min read, Case study. Original: [https://blog.railway.com/p/twin-macro-tailwind-migration](https://blog.railway.com/p/twin-macro-tailwind-migration)

## Summary

Railway 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.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [CSS](https://swe.quest/tags/css.md) (Web & mobile)
- [Frontend](https://swe.quest/tags/frontend.md) (Web & mobile)
- [Refactoring & migrations](https://swe.quest/tags/refactoring.md) (Engineering practices)
- [Build systems](https://swe.quest/tags/build-systems.md) (Engineering practices)
- [React](https://swe.quest/tags/react.md) (Web & mobile)

## Prerequisites

- Tailwind CSS ([easy posts on CSS](https://swe.quest/tags/css.md?difficulty=easy))
- React styled-components ([easy posts on React](https://swe.quest/tags/react.md?difficulty=easy))
- JavaScript transpilers like Babel ([easy posts on JavaScript](https://swe.quest/tags/javascript.md?difficulty=easy))

## Keywords

twin.macro, Tailwind CSS, SWC, Babel, tailwind-merge, styled-components, Nx

## Related posts

- [Moving Railway's Frontend Off Next.js](https://swe.quest/articles/moving-railway-s-frontend-off-next-js-a0f8a20e0dc7a7ef.md): Railway · 2026-04-03 · Medium · 5 min read · Frontend, React, Refactoring & migrations, Build systems, CDN & edge
  Railway migrated its entire production frontend (dashboard, canvas, marketing site, 200+ routes) from the Next.js Pages Router to Vite + TanStack Router/Start in two PRs with zero downtime.
- [Improving site performance by shipping more CSS](https://swe.quest/articles/improving-site-performance-by-shipping-more-css-41480dcc45d65149.md): GitHub Engineering · 2026-09-25 · Medium · 7 min read · CSS, Web performance, Refactoring & migrations, Design systems, React
  GitHub 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.
- [Hydrogen & Tailwind: The Perfect Match for Building Beautiful Storefronts](https://swe.quest/articles/hydrogen-tailwind-the-perfect-match-for-building-beautiful-storefronts-f351623f38eedf37.md): Shopify Engineering · 2022-02-11 · Medium · 10 min read · CSS, Frontend, React, E-commerce, Design systems
  Tailwind'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.
- [How we use Web Components at GitHub](https://swe.quest/articles/how-we-use-web-components-at-github-43357e36de1ecc50.md): GitHub Engineering · 2021-05-04 · Medium · 8 min read · Frontend, Browsers, Design systems, TypeScript, Refactoring & migrations
  GitHub moved from jQuery to native Web Components starting in 2014 and now ships dozens of custom elements such as \<include-fragment\>, \<details-dialog\> and \<relative-time\>.
- [Upgrading Checkout Blocks app to Polaris web components](https://swe.quest/articles/upgrading-checkout-blocks-app-to-polaris-web-components-6cf6ef4febe89e45.md): Shopify Engineering · 2026-07-16 · Medium · 10 min read · Frontend, Web performance, Refactoring & migrations, React, E-commerce
  Shopify's Checkout Blocks team migrated five high-traffic checkout UI extensions from React and the legacy Remote UI bridge to Preact, remote-dom and Polaris web components, rewriting them in TypeScript, and cut transferred bundle sizes by 40-85% and extension load time by about 8% at P50.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
