For most projects (and to take advantage of Tailwind's customization features), you'll want to install Tailwind via npm.
# Using npm
npm install tailwindcss
Install the dependencies in the local node_modules folder.
npm install
How you actually build your project will depend on the tools that you’re using. Your framework may include a command like npm run dev
to start a development server that compiles your CSS in the background,
npm run dev
Use the @tailwind
directive to inject Tailwind's base
, components
, and utilities
styles into your CSS:
/* ./resources/css/app.css */
@tailwind base;
@tailwind components;
@tailwind utilities;
In your webpack.mix.js, add tailwindcss as a PostCSS plugin:
// webpack.mix.js
mix.js("resources/js/app.js", "public/js")
.postCss("resources/css/app.css", "public/css", [
require("tailwindcss"),
]);
npm run dev
Next, import your stylesheet in your main Blade layout (commonly resources/views/layouts/app.blade.php
or similar) and add the responsive viewport meta tag if it’s not already present:
<!DOCTYPE html>
<head>
<!-- ... --->
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link href="{{ asset('css/app.css') }}" rel="stylesheet">
</head>
<!-- ... --->