Index
[Astro] Set up a new Astro project with Tailwind CSS
Tested with: Astro v5 • Tailwind CSS v4
-
Use the Astro
createCLI command, specifying that you want Tailwind added, and follow the wizard to generate a project.Terminal window npm create astro@latest -- --add tailwindTerminal window yarn create astro@latest --add tailwindTerminal window pnpm create astro@latest --add tailwind -
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";--- -
Navigate into the project directory and start the development server.
Terminal window cd <project-name>Terminal window npm run devTerminal window yarn run devTerminal window pnpm run dev
Alternative: official Astro with Tailwind template
You can also use the official “Astro with Tailwind” template.
npm create astro@latest -- --template with-tailwindcssyarn create astro@latest --template with-tailwindcsspnpm create astro@latest --template with-tailwindcss