Tailwind CSS v4 Not Working with Laravel Livewire
Hi everyone,
I’m having trouble getting Tailwind CSS v4 to work with Laravel Livewire. I’ve followed the new Tailwind CSS v4 setup, but the styles aren’t being applied to my Livewire component. Here’s what I’ve done so far:
I have installed the new laravel kit with livewire and everything is setup but I create a livewire component and use
Route::view("customRegister",'Livewire.customregister');
and I styled the customregister but it did not work there are components laravel (v12 )install with the new kit they use tailwind v4 and it work for them
I am noobie please help
@Sinnbeck yeah I use cli composer dev and also tried the npm run dev
but still wont work
as I told you the there are components that laravel provider with the new start kit but when I create one using cli command
php artisan make:volt "name"
no style appieled such as flex bg-green-500 px-2 ... etc
app.css configure to style every page on the views folder
// app.css page
@import 'tailwindcss';
@Sinnbeck I think I figure out the component should be wrapper inside a layout and my component, I want to use it as page which mean that there is no header to apply the this @vite('resources/css/app.css')
solution :
I create blade page call it custome and apply @vite('resources/css/app.css') on it
then import the livewire component and yeah this fix my problem
but I question can I use livewire as page with layout somthing I can import vite to my component and work right out of the box
It appears that Tailwind is not working with the Laravel 12 Starter Kit for Livewire.
This got it working for me:
Level 1
adrianojsle
Posted 3 months ago
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"