- Use the following command to install tailwind through npm
npm install -D tailwindcss
- Create your
tailwind.config.js
file using : npx tailwindcss init
- Configure your template paths:
/** @type {import('tailwindcss').Config} */
module.exports = {
content: ["./src/**/*.{html,js}"],
theme: {
extend: {},
},
plugins: [],
}
- Add the
@tailwind
directives for each of Tailwind’s layers to your main CSS file : @tailwind base;
@tailwind components;
@tailwind utilities;
- Start the Tailwind CLI build process:
npx tailwindcss -i ./src/input.css -o ./dist/output.css --watch
- Add your compiled CSS file to the and start using Tailwind’s utility classes to style your content:
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="/dist/output.css" rel="stylesheet">
</head>
<body>
<h1 class="text-3xl font-bold underline">
Hello world!
</h1>
</body>
</html>