1. Play CDN (for learning)
One script tag, no build step:
<script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script>
Great for practice and demos, but not for production — it is slower and larger.
2. Vite plugin (Laravel, React, Vue)
npm install tailwindcss @tailwindcss/vite
Add the plugin in vite.config.js:
import tailwindcss from '@tailwindcss/vite';
export default { plugins: [tailwindcss()] };
Then in your CSS file:
@import "tailwindcss";
New Laravel projects already come with Tailwind set up this way.
3. Tailwind CLI (plain HTML projects)
npx @tailwindcss/cli -i ./src/input.css -o ./dist/output.css --watch
What changed in v4
- No
tailwind.config.jsneeded — configure in CSS with@theme - One line
@import "tailwindcss";replaces the old three@tailwindlines - Automatic detection of your template files
- Much faster builds
Example
Example — Starter page with the Play CDN
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Tailwind Starter</title>
<script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script>
</head>
<body class="bg-gray-50 text-gray-800">
<main class="max-w-3xl mx-auto p-6">
<h1 class="text-3xl font-bold underline decoration-sky-500">My Tailwind Page</h1>
<p class="mt-3">Start building here.</p>
</main>
</body>
</html>