How to add css to custom theme?
Hi Guys,
Can someone please explain to me like to a 5 year old how to use full tailwindcss class. I know I should put it in a custom theme css but how exactly? Which files to modify and where? I know about custom themes https://filamentphp.com/docs/3.x/panels/themes#creating-a-custom-theme but how to add whole tailwindcss to it for local dev and then purge it? I'm using vite. Thank you so much!
22 Replies
When you run php artisan make:filament-theme it generates you the files and away you go, add the css and run npm run build. Providing you followed all the steps that CSS will then be used
Yes but how to add whole tailwindcss to the files and which files exactly?
It happens as part of the generation
You don't add the whole, vite builds what is used in the blade files.
But run dev does not add the classes I used and im still missing classes
Where are you using the classes?
Have you configured filament to use this css file
Yes
Ok, so where are you using the classes? The tailwind theme doesn't use classes it includes them, so you must be using them somewhere. Where are you defining the use of classes that are not included
In the custom View::make in a panel.
So in the view::make are you including a blade view? That is where the CSS classes should be used, then when runnin npm run build, it will add those css classes into your theme.
Yes, let me try this again if you say it should work
Ok it definately works now as I have lost all of my styles. hat should be the contects of theme.css?
I created theme for wrong panel.
vite.config.js
AppPAnelProvider:
recources/css/filament/app/tailwind.config.js
postcss.config.js
resources/css/filament/app/theme.css
I have no idea why this does not work, or maybe it is that vite is doing only the main and tailwind.config file and not the theme one?
What doesn't work?
In my resource I Class I have:
then in the view card.blade.php I try to use h-20 and it does not work
Are the configurations files correct?
You need to add your views path to the tailwind.config.js
Thanks it seems to work now! I have put my custom view in incorrect directory! Now I have a strange different error.
yarn build - works, but yarn dev does not, it does not compile any styles and page is displayed as would be without any styles, what am I missing?
What errors are you seeing in the console?
No errors whatsoever. The vite dev just does not compile. I reverted to use vite build —watch and it works as expected no idea whats the story with dev tough
I suspect you are running yarn dev and accessing over the url it provides? Why use Yarn and not NPM when we natively run as npm?
every time I had npm issues the same packages lists was installed without error with yarn. Sick and tired of fixing npm errors. Anyway "vite build —watch" works and thats good enough for me. Thank you!
Sounds like NPM is respecting the lock file if you are getting errors.
Thank you for you help. I'm not using NPM.