Tailwind content detection in custom theme not working
I setup a fresh installation of laravel 10 and filament 3.
Unfortunately I can't get the custom theme to work properly to get access to all the tailwind css classes.
I followed the steps in the documentation (https://filamentphp.com/docs/3.x/panels/themes#creating-a-custom-theme) to create a custom theme.
But when I run the build script (
sail npm run build
), I get this warning, and the classes used in my blade files are not available:
resources/css/filament/admin/theme.css
resources/css/filament/admin/tailwind.config.js
vite.config.js
If I add a tailwind.config.js
in the project root and add some content
entries there, the warning disappears, but still the css classes are missing.
If I add a syntax error to the resources/css/filament/admin/tailwind.config.js
the build process fails, so it appears to read it.
Can someone help me?31 Replies
Can somebody please help me? I'm really stuck here π¦
Did you add the ->viteTheme() to your panel?
Yes I did:
->viteTheme('resources/css/filament/admin/theme.css')
If I add a background color to theme.css it worksDo you have @config() in your theme.css?
It could be that itβs trying to use the tailwind config in root.
Also your getting that content error because of your app.css.
I would recommend not having a tailwindconfig in the root. If you need it for app you can move it and then reference it in app.css with @config().
Sounds like something just isnβt configured right. Hard to say what though.
Yes, I have the @config part
@config './tailwind.config.js';
My resources/css/app.css
is an empty file. Even if I remove it from the vite input config, the error still persists
I don't have a tailwind config in the project root, I just temporarily added it to check if it changes anything.
As I didn't change anything stylewise so far, I could remove everything that could interfere and start fresh.
Do you can maybe sent me all the default config files regarding this tailwind issue that should work out of the box? I used "admin" as my panel name, and it is a fresh and clean laravel 10 filament 3 install.so the theme is actually working?
you're just concerned about the content warning
this is my typical setup, but my frontend and backend are seperate so I have to have two configs and stylesheets.
Yes and no π
theme.css and build process works.
With this content, the background color will get red.
But it seems like the
content
part from the tailwind config doesnt work, because the used classes aren't recognized
looks identical to me π¦
hmm. not seeing anything off in the code you shared.
I added the css-class
w-36
to a select:
$this->extraInputAttributes(['class' => 'state-column w-36'], true);
In the dev-tools in the browser, I can see that the class is added
ARGH!!!where are you calling
$this->extraInputAttributes()
i'm so sorry...I just found my mistake :/
Solution
I was missing
/Tables/**/*.php',
in the tailwind config..no worries, sometimes we just have to talk through it.
I once had the class directly in the blade-template, but moved it..
but yea, that's why i was asking about where you were calling it.
and then I didn't added the path :/
glad you found it though. π
would it hurt to tell tailwind to look into every file in app? π
yes
damn π
can I buy you a coffee for your wasted time?
it's a parser so if you include a file that has characters it that it can't handle it'll break the build.
no need. thank you though.,
I see...I hope I don't make the same mistake again π
happens to us all.
you should consider adding a github sponser like Dennis Koch π
Thanks again for your help and have a great weekend π
Isnβt worth it for support here π
Thinks can change π
Donβt think so π
Maybe people need a friendly reminder π
Like if the conversation in a topic exceeds 5 message or so with one of you, there could be a nice bump: "Want to sponsor me a beer/coffee/whatever" π