This guide will help you set up and use Tailwind CSS in your project using the Tailwind CLI.
- Node.js and npm should be installed on your machine.
- Tailwind CSS is already set up in your project.
-
Ensure Tailwind CSS is installed:
If Tailwind CSS is not installed, run the following command in your project directory:
npm install tailwindcss
-
Verify Tailwind Configuration:
Ensure you have a
tailwind.config.js
file. If not, create one using:npx tailwindcss init
-
CSS File Setup:
Ensure your
input.css
file includes the Tailwind directives:@tailwind base; @tailwind components; @tailwind utilities;
-
Build your CSS:
Use the Tailwind CLI to compile your CSS. The command is already set up in your
package.json
:"scripts": { "watch": "npx tailwindcss -i ./form_campaign_app/static/tailwind/input.css -o ./form_campaign_app/static/tailwind/output.css --watch" }
Run the build script to generate your CSS:
npm run watch
-
Include the compiled CSS in your HTML:
Link the compiled CSS file in your HTML file:
<link href="/form_campaign_app/static/tailwind/output.css" rel="stylesheet">
- To watch for changes and automatically rebuild your CSS, use the
watch
script as shown above.