You went to the correct tab?
https://tailwindcss.com/docs/installation/framework-guides/laravel/vite
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I have been trying for hours now to get the new tailwind to work with laravel and nothing seems to work. I even tried setting up a new project following the instruction on the tailwind website and nothing seems to work. Is anyone else having these issues?
I can get other versions to work but just not 4.
You went to the correct tab?
https://tailwindcss.com/docs/installation/framework-guides/laravel/vite
@jlrdw sure did I can record a video and upload it to youtube in a bit also I followed the directions exactly.
Here is my vite config https://snipboard.io/5Zo6Nk.jpg
Here is my app.css https://snipboard.io/EvBWmc.jpg
here is my view https://snipboard.io/VFb49k.jpg
to install tailwind in the project directory i ran. npm install tailwindcss @tailwindcss/vite
then updated my files then
npm run dev
Ive even tried npm install just in case there were any missing files. and there were but also that didnt fix the issue.
and here is the error when i try to build https://snipboard.io/5HXTlB.jpg
Here is a short video showing what I am doing
Before proceeding, remove any existing Tailwind CSS and PostCSS npm packages to avoid conflicts:
npm uninstall tailwindcss postcss
npm i -D tailwindcss @tailwindcss/postcss
postcss.config.js file:plugins: {
"@tailwindcss/postcss": {}
}
app.css file: @import "tailwindcss";
@vite(['resources/css/app.css'])
npm run dev
If auto-completion for Tailwind CSS doesn’t work in your Laravel Blade files, add the following to your settings.json file:
"files.associations": {
"*.css": "tailwindcss"
},
"editor.quickSuggestions": {
"strings": "on"
},
With these steps, your Tailwind CSS setup and development experience should work smoothly!
@RemiM unfortunately this also didn't work its still the same. The errors didn't even change.
@funkyjamma Just to be sure, did you remove the old tailwind devDependencies from your package.json before installing the new packages?
Anyway, you shouldn’t need anything else to get it running.
Also, make sure you're not importing Tailwind in your vite.config.js file. It should look like this (as generated by a fresh Laravel install):
import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
export default defineConfig({
plugins: [
laravel({
input: ['resources/css/app.css', 'resources/js/app.js'],
refresh: true,
}),
],
});
The full postcss.config.js file:
export default {
plugins: {
"@tailwindcss/postcss": {},
autoprefixer: {},
},
};
The full barebone app.css:
@import "tailwindcss";
@RemiM yeah i even started a whole new project to test your instructions it didnt work. My files look like you state.
I just removed it from vite and now i get this error.
in order to even view these error i need to run npm run build, npm run dev shows no error but also just doesnt work.
https://snipboard.io/mu67W1.jpg
I just noticed the package.json part i think this is where my issue may be. Do i just delete the tailwind thats there or do i need to change the version number?
I figured it out It got rid of the errors but now its just not working without errors.
Can you perhaps put the test app on github so we can test it ?
@funkyjamma Remove the old entries in the package.json. The tailwind and the postcss lines entirely. Then process to install the new package.
@RemiM i figured it out but now its just not working without errors. I have uploaded it to github.
@RemiM this works only when i run dev build when i do dev run it doesnt work.
Just to confirm, you keep npm run dev running in the background while developing, right?
Also, it might be helpful to clarify: npm run dev is used for development purposes, providing a live-reloading server, whereas npm run build generates an optimized production-ready build of your application.
@RemiM thanks very much
@RemiM This work perfectly
I had the exact same problem as @funkyjamma on a new Laravel project created with Herd but I followed @RemiM instructions and it now works.
@funkyjamma just run npm install @tailwindcss/postcss and then relaunch npm run dev
This package is problably missing in your package.json.
The bug happens because the recent version of Laravel already comes with a pre-installed version of Tailwind. Do the following:
1- Remove all Tailwind and PostCSS dependencies from the package.json file 2- Run "npm i -c" 3- Follow all the steps from tutorial Tailwind Vite Laravel official doc 4- Run "npm i @tailwindcss/postcss" 5- Change the postcss.config.js to: export default { plugins: { "@tailwindcss/postcss": {}, autoprefixer: {}, }, }; 6- Run "npm run dev -c"
@adrianojsle Thanks, work for me. But my project Laravel 11 + React
@adrianojsle Thank you very much it works for me, I must say that I really struggled while the solution was so simple. I would like to know if you can help me to solve the problems of importing external plugins with version 4 of tailwindcss since in previous versions it was done in the tailwind.config.js file in the plugin part and in v4 when I try to import the plugins from postcss.config.js it gives me errors. And the plugin concerns the Preline package which is also a library of pretty great components based on tailwind
@adrianojsle thankyou very much, it's work for mee finally
@adrianojsle Hi @adrianojsle. Thank you. Your advice worked for me. I have a Laravel 12 Livewire starter kit installation and your advice was the only thing on the Internet that helped me.
I created a fresh install and was getting the same message when trying to use Tailwind so I followed @RemiM's instructions. The following is a summary of the process I followed:
tailwindcss and postcss dependencies from package.json.tailwindcss and tailwindcss/postcss via the terminalnpm i -D tailwindcss @tailwindcss/postcss
tailwindcss plugin in postcss.config.js with 'tailwindcss/postcssexport default {
plugins: {
"@tailwindcss/postcss": {},
autoprefixer: {},
},
};
app.css and replace them with the new import.@import "tailwindcss";
app.css file in your root Blade template. To test you can replace the markup in welcome.blade.php with the following:<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Laravel</title>
<!-- Fonts -->
<link rel="preconnect" href="https://fonts.bunny.net">
<link href="https://fonts.bunny.net/css?family=figtree:400,500,600&display=swap" rel="stylesheet" />
@vite(['resources/css/app.css', 'resources/js/app.js'])
</head>
<body class="font-sans antialiased dark:bg-black dark:text-white/50">
<h1 class="text-center text-3xl text-yellow-600">Test Tailwind</h1>
</body>
</html>
I've tested this twice with a new Laravel project and it works. Thanks to @remiM.
@Curtmantle Thank you! This is what I needed.
In my existing Laravel 11 projects, I did this:
Uninstalled everything related to old Tailwind CSS
npm uninstall tailwindcss postcss autoprefixer @tailwindcss/forms @tailwindcss/typography
I followed the official instructions on how to install Tailwind 4 with Laravel: https://tailwindcss.com/docs/installation/framework-guides/laravel/vite
And it worked without any problem.
this did the trick!
If you've followed the Tailwind v4 Laravel specific instructions at
https://tailwindcss.com/docs/installation/framework-guides/laravel/vite
but you're getting an error about postcss, delete your config file.
rm postcss.config.js
The instructions don't say to remove it. But it comes with Laravel. And its presence gets Vite confused about what you're trying to do.
Let's wait for Laravel's official support for Tailwind 4.
Tailwind's documentation is not useful.
I had the same case, to solved this please remove postcss.config.js file and these two packages from your package.json
"postcss": "^8.4.47",
"tailwindcss": "^3.4.13",
Then run npm install && npm install tailwindcss @tailwindcss/vite after that please follow the installation instruction from tailwindcss, and run npm run dev again.
It should be works correctly
@funkyjamma I simply upgraded from tailwind v3 to tailwind v4 in my laravel version 11 + inertia js 2.0 + react + typescript project by following the official upgrade guide from tailwind.
Before attempting this create a new branch of your project since the following commands will also modify your source files.
Simply run the following command:
npx @tailwindcss/upgrade
OR if you are using sail, prefix sail infront of the command:
sail npx @tailwindcss/upgrade
NOTE: remember to re run the npm server or rebuild assets after this with either of the below commands.
npm run dev
or
npm run build
OR if you are using sail
sail npm run dev
or
sail npm run build
This will upgrade everything including your npm dependencies, your previous config files and also your source files since several breaking changes were introduced.
You might want to watch for some edge cases before committing the changes though!
However fear not the above command worked as is and I had to do almost 0 changes. It even properly copied all my shadcn theme variables to resources/app.css and cleared some of the edge cases too!
The only thing I had to look out for was some hotfix I used for incorrect popover width for some shadcn components which was nothing major (just a minor visual bug) and it affected only 2 files. The fix was already available on github discussions and that solved it!! Just remember that if you were using some bruteforce or hacky tailwind solutions, you might want to look out for those!
I tried everything here. Wasted 5-6 hours on this and still could not get tailwind 4 to work. I have a Laravel install that was originally Laravel version 9 but was upgraded to v.11 about six months ago. I'm also running Filament 3 which complicates things maybe.
I really wish front end developers who produce open source packages would limit their caffeine intake and get some deep hobbies. The speed at which they feel the need to "innovate", push code and otherwise waste thousands of collective man-hours by constantly changing protocols and inventing new ways to complicate front end tech is mind boggling.
The new goal for front end package devs should be to see how few git pushes they can make.
Hi,
I don't know if I missed something here but as I see it author is trying to make it work with VITE and all the tutorials are for POSTCSS.
Never the less it did help me find a solution!
I have fresh Laravel 12 project and I followed all the instructions for TAILWIND/VITE and it didn't work.
In this post I found command: npm uninstall tailwindcss postcss
And after I ran it, it started working!
Hey Bro I got a fix for You Whenever u start a new Laravel 12 Project just run this command in the project directory .
npm install --save-dev vite laravel-vite-plugin
then when you want to run your application just run "npm run dev" and "php artisan serve"
and include this in every blade.php file in the head section
@vite(['resources/css/app.css', 'resources/js/app.js'])
This is the one and only fix that i have got so far and works wonders .
@Lazyy it works right off setting up a new app now. This was a bug very specific to when it first came out.
I struggled to bootstrap Tailwind CSS 4 (TW4) in a fresh Laravel 12 project using Blade templating, as the official Tailwind docs focus on SPA setups (React, Vue, etc.), and Laravel’s default Vite integration is tailored for Tailwind CSS 3 (TW3). Specifically, the laravel-vite-plugin and @vite directive rely on TW3’s PostCSS workflow, pulling in unnecessary dependencies like postcss, tailwindcss, and autoprefixer, and causing asset path issues (e.g., url(/assets/...) breaking in production). My solution was to drop all TW3-related packages, install TW4’s @tailwindcss/vite plugin, and create a custom ViteServiceProvider to replace laravel-vite-plugin’s functionality. This approach eliminates PostCSS, ensures TW4 compatibility, and uses base: './' in vite.config.js for portable asset paths (e.g., url(./...)) that work on subdomains (e.g., sub.example.com) or subfolders. Below are the steps and code to make it work seamlessly.
npm uninstall laravel-vite-plugin tailwindcss postcss autoprefixer
Delete postcss.config.js if present.
npm install @tailwindcss/vite
import { defineConfig } from 'vite';
import tailwindcss from '@tailwindcss/vite';
export default defineConfig({
plugins: [
tailwindcss(),
{
name: 'blade-reload',
handleHotUpdate({ file, server }) {
if (file.endsWith('.blade.php') || file.endsWith('.php')) {
server.ws.send({
type: 'full-reload',
path: '*',
});
}
},
},
],
server: {
hmr: true,
host: 'localhost',
port: 5173,
watch: {
usePolling: true,
},
},
css: {
postcss: null,
},
build: {
outDir: 'public/build',
assetsDir: 'assets',
manifest: true,
rollupOptions: {
input: [
'resources/css/app.css',
'resources/js/app.js',
],
},
},
base: './',
});
php artisan make:provider ViteServiceProvider
Define a custom @vite directive to load assets from public/build/.vite/manifest.json in production or Vite’s dev server in development.
please pay attention to the ***** below $viteBaseUrl it shoul have the value of local host port 5173 prefixed by http - there is a filtering option active that prevents me from posting links in the post
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\Facades\File;
class ViteServiceProvider extends ServiceProvider
{
public function boot()
{
Blade::directive('vite', function ($expression) {
$entries = eval("return $expression;");
if (!is_array($entries)) {
$entries = [$entries];
}
if (app()->environment('local', 'development')) {
$viteBaseUrl = ****** ;
$html = "<script type=\"module\" src=\"{$viteBaseUrl}/@vite/client\"></script>\n";
foreach ($entries as $entry) {
if (str_ends_with($entry, '.css')) {
$html .= "<link rel=\"stylesheet\" href=\"{$viteBaseUrl}/{$entry}\">\n";
} elseif (str_ends_with($entry, '.js')) {
$html .= "<script type=\"module\" src=\"{$viteBaseUrl}/{$entry}\"></script>\n";
}
}
return $html;
}
$manifestPath = public_path('build/.vite/manifest.json');
if (!File::exists($manifestPath)) {
return '';
}
$manifest = json_decode(File::get($manifestPath), true);
if (!$manifest) {
return '';
}
$html = '';
foreach ($entries as $entry) {
if (isset($manifest[$entry])) {
$asset = $manifest[$entry];
if (str_ends_with($entry, '.css')) {
$html .= "<link rel=\"stylesheet\" href=\"/build/{$asset['file']}\">\n";
} elseif (str_ends_with($entry, '.js')) {
$html .= "<script type=\"module\" src=\"/build/{$asset['file']}\"></script>\n";
}
}
}
return $html;
});
}
}
@vite(['resources/css/app.css', 'resources/js/app.js'])
7.Set Up CSS with the new Tailwind 4 directive: In resources/css/app.css (remove the old tw3)
@import "tailwindcss";
php artisan cache:clear
php artisan config:clear
php artisan view:clear
composer run dev
APP_ENV=production
build production assets
npm run build
start the laravel server without vite server
php artisan serve
This setup eliminates PostCSS bloat, simplifies TW4 integration, and supports Blade templating with flexible asset paths. Hope this helps others facing the same issue!
I just follow the cli instructions and dont get involved with vite at all. Simple as...
Please or to participate in this conversation.