Installation in TailwindCSS
Here's how you can install Tailwind CSS in your project depending on the environment you're using:
? 1. Install via CLI (Quickest Way for Beginners)
This sets up Tailwind with default config using PostCSS and a single CSS file.
Steps:
npx tailwindcss init -pThis creates:
tailwind.config.jspostcss.config.js
Then, in your CSS file (e.g., input.css):
@tailwind base;@tailwind components;@tailwind utilities;Then build:
npx tailwindcss -i ./input.css -o ./dist/output.css --watchUse output.css in your HTML file:
<link href="dist/output.css" rel="stylesheet">? 2. Install via npm (For Frameworks like React, Vue, Laravel, etc.)
Step-by-step:
npm install -D tailwindcssnpx tailwindcss initThen in tailwind.config.js, configure your content paths:
module.exports = { content: ["./*.html"], // or ["./src/**/*.{js,ts,jsx,tsx}"] theme: { extend: {}, }, plugins: [],}Add Tailwind to your CSS:
/* styles.css */@tailwind base;@tailwind components;@tailwind utilities;Add a build script in package.json:
"scripts": { "build": "tailwindcss -i ./styles.css -o ./output.css --watch"}Then run:
npm run build? 3. Via CDN (For Rapid Prototyping Only)
Add this line to your HTML <head>:
<script src="https://cdn.tailwindcss.com"></script>?? Only use for quick demos. No custom config or purge, so it’s not optimized.
Would you like a ready-made HTML + Tailwind starter template?