Skip to content
Index

[Astro] Set up a new Astro project with Tailwind CSS

Tested with: Astro v5 • Tailwind CSS v4

  1. Use the Astro create CLI command, specifying that you want Tailwind added, and follow the wizard to generate a project.

    Terminal window
    npm create astro@latest -- --add tailwind
  2. Depending on which template you selected when creating the project, you may need to import the stylesheet into your layout component, to make sure Tailwind styles are applied to all pages using that layout. Example:

    src/layouts/Layout.astro
    ---
    import "../styles/global.css";
    ---
  3. Navigate into the project directory and start the development server.

    Terminal window
    cd <project-name>
    Terminal window
    npm run dev

Alternative: official Astro with Tailwind template

You can also use the official “Astro with Tailwind” template.

Terminal window
npm create astro@latest -- --template with-tailwindcss