π How to Use Tailwind v3 for Filament v3 While Keeping Tailwind v4 in Laravel 12 (Using Vite Separation)
Problem: Laravel 12 supports Tailwind CSS v4, but Filament v3 is tied to Tailwind v3. Using both together can cause conflicts.
This guide shows how I solved the problem by isolating Filamentβs frontend stack β with its own Tailwind v3, Vite config, and PostCSS config β separate from the Laravel app, which uses Tailwind v4.
I alias Tailwind v4 as tailwindcss4
for Laravel and keep the default tailwindcss
(v3) for Filament.
bun install -D tailwindcss@^3 @tailwindcss/forms @tailwindcss/typography postcss postcss-nesting autoprefixer
bun install -D tailwindcss4@npm:tailwindcss@^4
php artisan make:filament-theme --pm=bun
Reorganize the generated files into a custom structure
resources/
βββ css/
β βββ app.css # Laravel (Tailwind v4)
βββ filament/
β βββ admin/
β β βββ css/
β β β βββ theme.css # Filament (Tailwind v3)
β β βββ js/
β β β βββ theme.js # Optional custom JS
β βββ postcss.config.js # PostCSS config for Tailwind v3
β βββ tailwind.config.js # Tailwind config for Filament
β βββ vite.config.js # Vite config just for Filament
Update resources/css/app.css
to use the alias tailwindcss4
@import 'tailwindcss4';
Fix the path of tailwind @config
in resources/filament/admin/css/theme.css
, Also place @import
in the top of file
@config '../../tailwind.config.js';
Fix the path of importing filament preset configurations in resources/filament/tailwind.config.js
import preset from '../../vendor/filament/filament/tailwind.config.preset'
Create resources/filament/vite.config.js
import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
export default defineConfig({
plugins: [
laravel({
hotFile: 'public/filament.hot', // will used for hot reload with (bun run fi-dev)
buildDirectory: 'fi-build', // to separate manifest.json
input: [
'resources/filament/admin/css/theme.css',
// 'resources/filament/admin/js/theme.js', // optional
],
refresh: true,
}),
],
css: {
postcss: 'resources/filament/postcss.config.js',
},
});
Create resources/filament/postcss.config.js
export default {
plugins: {
'tailwindcss/nesting': 'postcss-nesting',
tailwindcss: {},
autoprefixer: {},
},
}
Update package.json
by adding fi-build
and fi-dev
to scripts
{
"scripts": {
"fi-build": "vite build --config resources/filament/vite.config.js",
"fi-dev": "vite --config resources/filament/vite.config.js",
"build": "vite build",
"dev": "vite"
},
}
We need to tell laravel vite to use the hot file filament.hot
and buil directory fi-build
php artisan make:middleware UseViteForFilament
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Vite;
use Symfony\Component\HttpFoundation\Response;
class UseViteForFilament
{
public function handle(Request $request, Closure $next): Response
{
Vite::useHotFile('filament.hot')->useBuildDirectory('fi-build');
return $next($request);
}
}
Update AdminPanelProvider.php
by adding the created middleware in ->middleware()
and theme style in ->viteTheme()
public function panel(Panel $panel): Panel
{
return $panel
...
->middleware([
...
\App\Http\Middleware\UseViteForFilament::class,
])
->viteTheme('resources/filament/admin/css/theme.css'); // Optional
}
# Filament-specific Vite output
/public/fi-build
/public/filament.hot
bun run dev # Start Vite in dev mode
bun run build # Build for production
bun run fi-dev # Start Vite for Filament theme (with hot reload)
bun run fi-build # Build Filament theme for production
β
You can run both dev
and fi-dev
in separate terminal tabs for full development experience.
Laravel App (Tailwind v4) | Filament Panel (Tailwind v3) |
---|---|
Uses tailwindcss4 alias |
Uses tailwindcss |
Standard Vite config | Custom resources/filament/vite.config.js |
No PostCSS config | Scoped PostCSS config |
Hot reload: public/hot |
Hot reload: public/filament.hot |
Build dir: public/build |
Build dir: public/fi-build |
Followed each step. Filament builds alright but the frontend now has an issue. See the screenshot.