
Upgrade to Astro v5 with Tailwind CSS v4
| Time to Read: 2 mins
Astro 5.0 has been released and has come with some pretty nice features such as:
- Using Vite v6
- Type safety around environment variables
- Optimised speed and memory usage for markdown and MDX content
- Server-side islands, which is by far the most impressive feature
However, Astro’s tailwind direct plugin has been deprecated in favour for using Vite Tailwind plugin, which was released in Tailwind v4, to integrate with Astro.
TailwindCSS v4 was also released recently and brings some changes significant changes:
- Themes as CSS variables
- CSS based tailwind configuration
- Better performance, 100x faster 🚀
- Simpler support and install + Vite plugin
- and more!
With all of that, upgrading Astro and Tailwind has never been easier since both offer upgrade tools, which will scan your code and make relevant changes, but if you’re currently using Tailwind v3 and Astro v4, it’s important to run Tailwind upgrade before Astro.
- Upgrade Tailwind:
pnpm dlx @tailwindcss/upgrade- Tailwind might not update some of the class renames, so it’s always good to scan your code to see if it updated them, e.g.
rounded-smshould now change torounded-xs. Renamed utilities:
| Tailwind v3 | Tailwind v4 |
|---|---|
shadow-sm | shadow-xs |
shadow | shadow-sm |
drop-shadow-sm | drop-shadow-xs |
drop-shadow | drop-shadow-sm |
blur-sm | blur-xs |
blur | blur-sm |
backdrop-blur-sm | backdrop-blur-xs |
backdrop-blur | backdrop-blur-sm |
rounded-sm | rounded-xs |
rounded | rounded-sm |
outline-none | outline-hidden |
ring | ring-3 |
- Uninstall Astro’s tailwind plugin:
pnpm uninstall @astrojs/tailwind...import tailwind from "@astrojs/tailwind";...
export default defineConfig({... integrations: [ sitemap(), tailwind(), mdx() ],...});- Upgrade Astro:
pnpm dlx @astrojs/upgradeIf you were using hybrid rendering, this has now been merged with static as default
...
export default defineConfig({... output: "hybrid"...});- Lastly you should be able to re-add tailwind back into the mix:
pnpm dlx astro add tailwindNow you should be able to run the project locally and hopefully nothing has broken or has changed, good luck!
