Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

codelyftlab's avatar

Installing Tailwindcss in Laravel 10.xx

Good evening, i tried installing Tailwindcss in my Laravel Project. Im following this guide. I got a problem when importing 3 lines in resources\css\app.css

@tailwind base;
@tailwind components;
@tailwind utilities;

I got a yellow warning saying "Unknown at rule @tailwind css(unknownAtRules)

0 likes
10 replies
LaryAI's avatar
Level 58

The error message "Unknown at rule @tailwind css(unknownAtRules)" suggests that the @tailwind directive is not recognized by the CSS processor being used in the Laravel project.

To resolve this issue, you need to make sure that you have properly set up Tailwind CSS in your Laravel project. Here are the steps you can follow:

  1. Install Tailwind CSS and its dependencies by running the following command in your Laravel project directory:
npm install tailwindcss postcss autoprefixer
  1. Generate the Tailwind CSS configuration file by running the following command:
npx tailwindcss init
  1. This will create a tailwind.config.js file in your project's root directory. Open this file and make sure it contains the following code:
module.exports = {
  purge: [],
  darkMode: false,
  theme: {
    extend: {},
  },
  variants: {},
  plugins: [],
}
  1. Next, you need to configure Laravel Mix to process your CSS files. Open your webpack.mix.js file and add the following code:
const mix = require('laravel-mix');

mix.postCss('resources/css/app.css', 'public/css', [
    require('tailwindcss'),
]);
  1. Now, you can remove the @tailwind directives from your resources/css/app.css file. Instead, you will import the compiled CSS file generated by Laravel Mix. Replace the contents of resources/css/app.css with the following line:
@import 'tailwindcss/base';
@import 'tailwindcss/components';
@import 'tailwindcss/utilities';
  1. Finally, run the following command to compile your CSS files:
npm run dev

After following these steps, the @tailwind directives should be recognized and your CSS should be compiled successfully.

codelyftlab's avatar

@MohamedTammam yeah, there is 2 option using vite and mix in the guide. So i move to mix and the yellow warning is gone.

MohamedTammam's avatar

@cnneinn That doesn't make sense. You can use Tailwind with Vite. The installation is straightforward.

Cushty's avatar

This may sound silly, but isnt tailwind already installed with Blade? Ive created a new project with blade and the tailwind config etc are present so it seems to be installed, do i need to add the @vite directive to actually use tailwind in a blade file? Thanks

MannyF's avatar

Hey, I've set up Tailwind CSS in my Laravel 10 project with Vite exactly like it is described here https://tailwindcss.com/docs/guides/laravel#vite

If I do npm run build or npm run dev, this error occurs:

vite v5.0.12 building for production...
✓ 1 modules transformed.
[vite:css] [postcss] tailwindcss is not defined
file: /.../resources/css/app.css:undefined:NaN
error during build:
ReferenceError: [postcss] tailwindcss is not defined
    at /.../tailwind.config.js:1:165
    at evalModule (/.../node_modules/jiti/dist/jiti.js:1:256443)
    at jiti (/.../node_modules/jiti/dist/jiti.js:1:254371)
    at /.../node_modules/tailwindcss/lib/lib/load-config.js:48:30
    at loadConfig (/.../node_modules/tailwindcss/lib/lib/load-config.js:50:6)
    at getTailwindConfig (/.../node_modules/tailwindcss/lib/lib/setupTrackingContext.js:71:116)
    at /.../node_modules/tailwindcss/lib/lib/setupTrackingContext.js:100:92
    at /.../node_modules/tailwindcss/lib/processTailwindFeatures.js:48:11
    at plugins (/.../node_modules/tailwindcss/lib/plugin.js:38:69)
    at LazyResult.runOnRoot (/.../node_modules/postcss/lib/lazy-result.js:329:16)
FAIL

How I can Fix this?

Please or to participate in this conversation.