Complete the code to add Tailwind CSS to your Astro project by installing the correct package.
npm install [1]The official way to integrate Tailwind CSS with Astro is to install the @astrojs/tailwind integration package. This handles the setup including Tailwind CSS itself.
Complete the code to create the Tailwind config file using the CLI command.
npx tailwindcss init [1]The command npx tailwindcss init -p creates both the tailwind.config.mjs and postcss.config.cjs files, which are required for Tailwind in Astro projects.
Fix the error in the Tailwind config file by completing the content paths array correctly.
export default {
content: [[1]],
theme: {
extend: {},
},
plugins: [],
}node_modules or dist which are not source files.The content array should include the source files where Tailwind classes are used. Usually, this is the src folder with extensions like astro, html, js, jsx, ts, and tsx.
Complete the astro.config.mjs code to add the Tailwind integration.
import [1] from "[2]"; integrations: [[1]()],
Import the Tailwind integration conventionally as tailwind from "@astrojs/tailwind", then add tailwind() to the integrations array in astro.config.mjs.
Fill all three blanks to configure Tailwind in Astro's main CSS file with directives for base, components, and utilities.
@tailwind [1]; @tailwind [2]; @tailwind [3];
Tailwind CSS requires three directives in your main CSS file: @tailwind base;, @tailwind components;, and @tailwind utilities; to include all parts of the framework.