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

peterhrobar's avatar

Tailwind classes are not avail in filament 3.x

I'm trying to add these tailwind classes in one of my blade views (resources/views/filament/widgets/.blade.php):

<h1 class="mb-4 text-4xl font-extrabold leading-none tracking-tight text-left text-gray-900 md:text-5xl lg:text-6xl dark:text-white">{{ __('Your text here') }}</h1>

As a matter of fact not even the h1 is showing up (text is just bold in the widget), not to mention basic tailwind staff like text-4xl etc.

In my resources/css/filament//tailwind.config.js file i have the following:

import preset from '../../../../vendor/filament/filament/tailwind.config.preset'

export default {
    presets: [preset],
    content: [
        './app/Filament/**/*.php',
        './resources/**/*.blade.php',
        './vendor/filament/**/*.blade.php',
    ],
}

In my vite.config.js i have this:

import { defineConfig } from 'vite'; import laravel from 'laravel-vite-plugin';

export default defineConfig({
    plugins: [
        laravel({
            input: [
                'resources/css/app.css', 
                'resources/css/filament/<panel name>/theme.css',
                'resources/js/app.js'
            ],
            refresh: true,
        }),
    ],
});

I have run npm run build to re-comile everything with vite.

Is there anything i missed?

0 likes
16 replies
LaryAI's avatar
Level 58

It seems like you're having trouble with Tailwind CSS classes not being applied in your Filament widgets. Here are a few steps you can take to troubleshoot and resolve the issue:

  1. Ensure Tailwind is Processing Your CSS File: Make sure that the CSS file where you're importing Tailwind is being processed by Vite and included in your build output. You should have an import statement for Tailwind CSS in your resources/css/app.css or resources/css/filament/<panel name>/theme.css file:

    @import 'tailwindcss/base';
    @import 'tailwindcss/components';
    @import 'tailwindcss/utilities';
    
  2. Check Your tailwind.config.js File: Verify that your tailwind.config.js file is correctly set up and that the content array includes the paths to all of your Blade templates where you want to use Tailwind classes. It looks like you're using a preset from Filament, which is good, but ensure that your custom paths are included as well.

    export default {
        presets: [preset],
        content: [
            './app/Filament/**/*.php',
            './resources/views/**/*.blade.php',
            './vendor/filament/**/*.blade.php',
            // Add any other paths where you use Tailwind classes
        ],
        // ... other Tailwind configuration
    }
    
  3. Check Your vite.config.js File: Ensure that your vite.config.js file is correctly set up to include your CSS files. You mentioned that you have a specific path for the Filament theme CSS. Make sure that the <panel name> placeholder is replaced with the actual name of the panel:

    import { defineConfig } from 'vite';
    import laravel from 'laravel-vite-plugin';
    
    export default defineConfig({
        plugins: [
            laravel({
                input: [
                    'resources/css/app.css',
                    'resources/css/filament/<actual panel name>/theme.css', // Replace <actual panel name> with the correct name
                    'resources/js/app.js'
                ],
                refresh: true,
            }),
        ],
    });
    
  4. Run Vite Build: After making any changes to your configuration files or your CSS, make sure to rebuild your assets with Vite:

    npm run build
    
  5. Clear Caches: Sometimes, old cached views or configurations can cause issues. Clear your Laravel caches to ensure that changes are picked up:

    php artisan optimize:clear
    
  6. Check the Output: After rebuilding your assets and clearing caches, check the output in your browser. Inspect the page to see if the Tailwind CSS classes are being applied and if the correct CSS file is being loaded.

If you've followed these steps and are still experiencing issues, it might be helpful to check the browser's console for any errors and ensure that there are no network issues preventing the CSS file from loading. Additionally, double-check that the paths in your tailwind.config.js and vite.config.js files are correct and that they match the structure of your project.

peterhrobar's avatar

If enybody interested .... i just missed the ->viteTheme configuration option from my panel configuration .... :-)

1 like
Rozindzakwan's avatar

@peterhrobar i'm sorry, i don't know if my question is related, but why classes on tailwind not all loaded in filament? i try using class but not showing style, can you help me?

jaseofspades88's avatar

npm run dev and your filament classes will be available if you have the correct files being watched

jaseofspades88's avatar

The same method applies, @Rozindzakwan. Run npm run dev and make the changes in the watched files, vite will pick up the changes and Tailwind will compile the classes. It's all documented very well. If it isn't working, what changed?

brahimoulhaj's avatar

Hi, I have the same issue when using a custom view. I added the @vite('resources/css/app.css') line at the top of my blade file and it works properly. I don't know if that is good but it works for me.

@vite('resources/css/app.css')
<x-filament-panels::page>
    <div class="grid grid-cols-3 gap-3">
        <div class="col-span-2 bg-white rounded border p-5">sd</div>
        <div class="col-span-1 bg-white rounded border p-5">sd</div>
    </div>
</x-filament-panels::page>
8 likes
getupkid203's avatar

I found that adding @vite('resources/css/app.css') to the component caused some x-vite ping issue in the network tab.

I had a similar issue with all of this. Followed the instructions clearly.

As per the AI response: "ensure that your custom paths are included as well."

It's a bit of a "gotcha" and I feel really should be emphasized in the documentation.

The default tailwind.config.js that filament generates resources/css/filament/{theme}/theme.css

import preset from '../../../../vendor/filament/filament/tailwind.config.preset'

export default {
    presets: [preset],
    content: [
        './app/Filament/**/*.php',
        './resources/views/filament/**/*.blade.php',
        './vendor/filament/**/*.blade.php'
    ],
}

There must be a reason why resources/views/filament/**/*.blade.php is generated by default instead of just resources/views/**/*.blade.php <- coz this would also pick up blade files inside resources/views/filament/ directory. So yeah, just needed to add resources/views/**/*.blade.php to the array. Or change resources/views/filament/**/*.blade.php to resources/views/**/*.blade.php

5 likes
pachristos's avatar

I was able to make this to work after adding "viteTheme" to panel provider:

class AdminPanelProvider extends PanelProvider
{
    public function panel(Panel $panel): Panel
    {
        return $panel
....
              ->viteTheme('resources/css/app.css')
              ;
    }
}
4 likes
dougkira's avatar

Why is this not a default config? Or at least in the filament docs? I'm trying to add a blade component to filament layout but the tailwind classes never got compiled for a whole month. Thank you!

1 like
markshowell's avatar

I had to create a theme with php artisan make:filament-theme then add that theme to my AdminPanelProvider

->viteTheme('resources/css/filament/cdss/theme.css')

Rafhael1's avatar

In addition to ->viteTheme config in you panel I also had to change the tailwind.config.js content array, for it was not mapping the folder where the blade files were (they were not in the 'defaut' folders)

Please or to participate in this conversation.