Skip to content

Tailwind v4 alpha

Astro ^4.0.0

Tailwind 4.0 plans to introduce some big changes, including a new Vite plugin, which will improve accuracy and performance.

On top of the Vite plugin v4 comes with some major changes, most notably a redesign of the tailwind.config.mjs. The plan is to continue to support using the existing configs, but steer users toward using the entry point .css file as the config file.


  1. Install Tailwind’s official Vite plugin

    Terminal window
    npm install --save-dev tailwindcss@next @tailwindcss/vite@next
  2. Add the plugin to Astro config and enable Lightning CSS

    import { defineConfig } from 'astro/config';
    import tailwindcss from '@tailwindcss/vite';
    export default defineConfig({
    vite: {
    plugins: [tailwindcss()],
  3. Import the CSS file that imports Tailwind into your .astro components

    Instead of Astro’s Tailwind integration importing the default Tailwind .css file for you, you’ll need to do this yourself. Either import this .css file into a shared layout, or into the individual .astro components/pages you’d like to use Tailwind in.

    @import "tailwindcss";
    import "../styles/tailwind.css";
    <!doctype html>
    <html lang="en">
    <!-- ... -->
    <article class="max-w-2xl">
    <slot />