Tailwind CSS version 4 introduces several significant enhancements over version 3, focusing on performance, modern web standards, and developer experience. Key differences include:
1. High-Performance Engine:
Version 4 features a ground-up rewrite of the framework, resulting in full builds up to 5 times faster and incremental builds over 100 times faster compared to version 3[1].
2. Modern Web Features:
Tailwind CSS v4 leverages cutting-edge CSS capabilities such as cascade layers, registered custom properties with @property, and color-mix(), enhancing flexibility and performance[1].
3. Simplified Installation:
The installation process has been streamlined, requiring fewer dependencies and minimal configuration. A single line of code in your CSS file is sufficient to get started[1].
4. First-Party Vite Plugin:
Version 4 introduces an official Vite plugin, providing tight integration for improved performance and reduced configuration[1].
5. Automatic Content Detection:
Tailwind CSS v4 automatically discovers all template files, eliminating the need for manual configuration of content paths[1].
6. CSS-First Configuration:
The configuration experience has been reimagined, allowing developers to customize and extend the framework directly within CSS using the @theme directive, replacing the previous JavaScript configuration file[1].
7. CSS Theme Variables:
All design tokens are now exposed as native CSS variables, enabling easy access and reuse throughout your stylesheets[1].
8. Dynamic Utility Values and Variants:
Version 4 supports dynamic utility values and variants, allowing for more flexible and intuitive class usage without extensive configuration[1].
9. Modernized P3 Color Palette:
The default color palette has been upgraded to use the oklch color space, offering more vivid colors that take full advantage of modern display technologies[1].
10. Container Queries:
First-class support for container queries has been added, enabling styling based on an element's container size without additional plugins[1].
11. Expanded Gradient APIs:
New utilities for radial and conic gradients, along with interpolation modes, provide more options for creating complex gradient effects[1].
These enhancements in Tailwind CSS v4 aim to provide a more efficient, flexible, and modern development experience compared to version 3.