DEV Community

Cover image for πŸš€ Tailwind CSS v4: What is New
Tim
Tim

Posted on

πŸš€ Tailwind CSS v4: What is New

Disclamer: This article has been written by ChatGPT based on scraped search results using LLMiner (search query -> to single markdown tool).


Tailwind CSS v4.0 has finally landed in beta, and oh boy, it’s packed with some groundbreaking changes that will supercharge your development workflow. From a blazing-fast engine rewrite to a sleek new CSS-first configuration, this release feels like putting jet fuel in your project. Whether you’re an existing Tailwind fan or a newcomer, buckle up as we explore everything that’s new in Tailwind CSS v4.0!


πŸ”₯ A New High-Performance Engine β€” Oxide

Tailwind CSS v4.0 introduces Oxide, a ground-up rewrite of its engine. The numbers are jaw-dropping:

Build Type Tailwind v3.4 Tailwind v4.0 Beta Improvement
Full Build 378ms 100ms πŸš€ 3.78x
Incremental Build (New CSS) 44ms 5ms πŸš€ 8.8x
Incremental Build (No New CSS) 35ms 192Β΅s πŸš€ 182x

Yes, you read that right β€” builds now complete in microseconds when no new CSS is generated.

This turbocharged speed comes from several key improvements:

  • Rust-Powered: Performance-critical parts of the framework are written in Rust.
  • Custom Parser: Tailwind ditches PostCSS for its own optimized parser.
  • Lightning CSS Integration: Transpiling, prefixing, and minification happen faster than ever.

🎯 Why Does It Matter?

The longer you work on a project, the more incremental builds you run. Now, every tweak feels instant. Faster builds mean more productivity β€” and more time to binge-watch that series you’ve been neglecting. 😎


🎨 CSS-First Configuration

Say goodbye to tailwind.config.js clutter. Tailwind CSS v4.0 lets you configure your design tokens directly in CSS with the new @theme directive:

@import "tailwindcss";

@theme {
  --color-primary: oklch(0.84 0.18 117.33);
  --font-sans: "Inter", sans-serif;
  --spacing: 0.25rem;
}
Enter fullscreen mode Exit fullscreen mode

This modernizes your workflow by aligning configurations closer to where they belong β€” your CSS.

πŸ’‘ Benefits

  • Less JavaScript: Reduce your JS footprint.
  • Native CSS Variables: Use theme values inline or with libraries like Motion.
  • Simplified Overrides: Easily extend or reset design tokens using --*: initial.

Need flexibility? Tailwind still supports the classic JS config for backward compatibility.


🌈 Modernized Colors with P3 Gamut

Colors in v4.0 now default to OKLCH instead of RGB, enabling:

  • Wider Gamut: More vibrant, modern colors.
  • Smooth Gradients: Better interpolation for gradient utilities.

Here’s a vivid example:

<div class="bg-linear-45 from-indigo-500 to-teal-400"></div>
Enter fullscreen mode Exit fullscreen mode

The improved gradients, combined with utilities like bg-conic-* and bg-radial-*, bring your designs to life with minimal effort.


πŸͺ„ Automatic Source Detection

Remember configuring the dreaded content array? Forget about it. Tailwind CSS v4.0 introduces zero-config content detection:

  • Automatically scans your project for templates.
  • Ignores .gitignore files, binary files, and junk.
  • Works seamlessly with Vite’s module graph.

For edge cases, you can explicitly add sources using the @source directive:

@import "tailwindcss";
@source "../node_modules/my-library/src/components";
Enter fullscreen mode Exit fullscreen mode

🀯 TL;DR:

Less setup, smarter detection, and fewer headaches.


πŸ“ Container Queries β€” Native Support

No more plugins! Tailwind v4.0 brings native container query support to the core library:

<div class="@container">
  <div class="grid grid-cols-3 @max-md:grid-cols-1">
    <!-- Magic happens here -->
  </div>
</div>
Enter fullscreen mode Exit fullscreen mode

You can even combine @min-* and @max-* variants for powerful responsive designs.


πŸ—οΈ Composable Variants

Variants in Tailwind CSS v4.0 are now composable. This means you can chain complex selectors like a boss:

<div class="group">
  <div class="group-has-data-active:opacity-100">
    <!-- Shine bright like a diamond -->
  </div>
</div>
Enter fullscreen mode Exit fullscreen mode

Want even more? Combine not-*, in-*, and has-* variants for ultimate flexibility.


🧊 3D Transforms

Tailwind CSS v4.0 introduces 3D transforms for the first time! Say hello to rotate-x-*, scale-z-*, translate-z-*, and more:

<div class="transform-3d rotate-x-45 scale-z-110 translate-z-20">
  Look, I’m in 3D!
</div>
Enter fullscreen mode Exit fullscreen mode

Want depth? Combine with perspective-* utilities:

<div class="perspective-normal">
  <div class="transform-3d rotate-x-30 shadow-lg">
    3D Shadow Power
  </div>
</div>
Enter fullscreen mode Exit fullscreen mode

🧹 Breaking Changes You Need to Know

Tailwind v4.0 cleans up some old baggage. Here are the key removals and changes:

  1. Removed Deprecated Utilities: Say goodbye to text-opacity-*, flex-grow-*, and others.
  2. No Default Border Color: border now defaults to currentColor.
  3. Rings Default to 1px: Consistent with using outline-* for focus rings.
  4. Separate CLI and PostCSS Plugins: Install these separately when needed.

Pro Tip: Use the Tailwind upgrade tool to migrate your project painlessly.


🏁 How to Upgrade to Tailwind CSS v4.0 Beta

Getting started is easy. Install the beta release and plugins of your choice:

Using Vite:

npm install tailwindcss@next @tailwindcss/vite@next
Enter fullscreen mode Exit fullscreen mode

Using PostCSS:

npm install tailwindcss@next @tailwindcss/postcss@next
Enter fullscreen mode Exit fullscreen mode

Using the CLI:

npm install tailwindcss@next @tailwindcss/cli@next
Enter fullscreen mode Exit fullscreen mode

Run the upgrade tool:

npx tailwindcss@next upgrade
Enter fullscreen mode Exit fullscreen mode

Test your project, fine-tune, and enjoy the ride!


πŸŽ‰ Wrapping Up

Tailwind CSS v4.0 is a game changer for modern web development. With its turbocharged Oxide engine, streamlined configuration, vibrant color updates, and powerful utilities, it’s hard not to be excited. This beta release already feels polished, and I can’t wait to see what developers build with it.

Ready to dive in? πŸš€ Upgrade now and let Tailwind v4.0 take your CSS workflow to the next level!


What’s your favorite new feature in Tailwind CSS v4.0? Drop a comment and let’s discuss!

Happy coding! πŸ‘¨β€πŸ’»πŸ‘©β€πŸ’»

`

Top comments (0)