Tutorials
10 min readNov 20, 2024

Migrating to Tailwind CSS v4: What You Need to Know

A step-by-step guide to upgrading your project to Tailwind CSS v4 with minimal disruption.

Sarah Miller

Design Lead

What's New in Tailwind v4

Tailwind CSS v4 brings significant changes to how we write and configure our styles. Let's explore what's new and how to migrate.

Major Changes

1. CSS-First Configuration

Configuration now lives in CSS:

@theme {

--color-primary-500: oklch(0.6 0.2 250);

--font-sans: 'Inter', sans-serif;

}

2. OKLCH Colors

Better color manipulation with OKLCH:

  • Perceptually uniform
  • Wider gamut support
  • Easier color math
  • 3. New Gradient Syntax

    <div class="bg-linear-to-r from-primary-500 to-secondary-500">

    Gradient content

    </div>

    4. Container Queries

    Built-in container query support:

    <div class="@container">

    <div class="@md:flex @lg:grid">

    Responsive to container

    </div>

    </div>

    Migration Steps

    Step 1: Update Dependencies

    npm install tailwindcss@latest

    Step 2: Convert Configuration

    Move from tailwind.config.js to CSS-based config.

    Step 3: Update Class Names

    Some utilities have been renamed:

  • `bg-gradient-to-r` → `bg-linear-to-r`
  • Color opacity syntax changes
  • Step 4: Test Thoroughly

  • Visual regression testing
  • Check all breakpoints
  • Verify dark mode
  • Common Issues

    Issue 1: Missing Colors

    Solution: Define colors in @theme block

    Issue 2: Plugin Compatibility

    Solution: Check for v4-compatible versions

    Issue 3: Build Errors

    Solution: Clear cache and rebuild

    Conclusion

    Tailwind v4 is a significant upgrade that modernizes the framework. Take time to migrate properly and enjoy the new features.

    Tags

    Tailwind CSSCSSMigrationTutorial

    Ready to Start Your Project?

    Let's discuss how we can help bring your vision to life.

    Get in Touch