Skip to content
Home / Migrations / styled-componentsTailwind CSS

styled-components Tailwind CSS

hard

Moving from runtime CSS-in-JS to utility-first CSS. Eliminates the styled-components runtime, reduces bundle size. Required for React Server Components which don't support runtime CSS-in-JS.

Estimated: 8-20h · 5 steps
Progress0%
Step 1: Install Tailwind
npm install tailwindcss @tailwindcss/postcss && npm uninstall styled-components
Step 2: Map design tokens

Extract colors, spacing, fonts from your styled-components theme into tailwind.config.ts. theme.colors, theme.spacing, etc.

Step 3: Convert components incrementally

Start with leaf components. styled.div`color: red; padding: 16px` → <div className='text-red-500 p-4'>. Use Tailwind IntelliSense extension.

Step 4: Handle dynamic styles

Template literal interpolation → Tailwind conditional classes with clsx/cn. ${props.primary ? 'blue' : 'gray'} → cn(props.primary ? 'bg-blue-500' : 'bg-gray-500').

Step 5: Remove ThemeProvider

Tailwind uses CSS variables via @theme. No React context needed for theming.

All components styled correctly. No styled-components imports remain. Bundle size reduced.