Learn how to upgrade to Tailwind CSS 4. Tailwind released version 4 that introduced many exciting features but also breaking changes. So how to upgrade Tailwind CSS from version 3 to version 4 without breaking the website?
- Tailwind CSS v4 is over 3.5x to 8x faster due to new high-performance engine.
- It supports new CSS features like registered custom properties, color mix, container queries, 3d transformation, @starting-style, and more.
- Installation process and configuration has been changed. Now it has fewer dependencies and zero configuration.
- All template files are automatically detected by Tailwind CSS 4 without any configuration.
- No tooling needed to bundle multiple imports.
- Now you can customize and extend Tailwind CSS 4 directly in CSS instead of a JavaScript configuration file.
- Access design tokens as native CSS variables.
- Color palette has been upgraded from rgb to oklch to make colors more vivid.
A lot has been changed. And it has breaking changes. They have developed a tailwind migration tool that can help you migrate to tailwind css 4 easily. But first create project backup or start a new branch.
For most projects, the upgrade tool will automate the entire migration process including updating your dependencies, migrating your configuration file to CSS, and handling any changes to your template files. The upgrade tool requires Node.js 20 or higher, so ensure your environment is updated before running it.
After upgrading it’s also a good idea to go over all of the breaking changes in v4 and get a good understanding of what’s changed, in case there are other things you need to update in your project that the upgrade tool doesn’t catch.
Further more they have:
- Removed deprecated utilities from v3 and introduced alternatives
- Some utilities were renamed for consistency
- Container configuration options were removed. You can extend container using utility directive
- There are other small changes
Old javascript config file is still supported for backwards compatibility but they are not detected automatically in v4. If you still need to use a JavaScript config file, you can load it explicitly using the @config directive.
– Add Tailwind CSS 4 to HTML using NPM and Tailwind CSS 4 CLI
– How to Use Tailwind CSS 4 in React JS
– Add Tailwind CSS 4 to HTML