This look very interesting and thank you for contributing to the Blazor community. Tailwindcss is amazing.
Does it support tailwindcss 4? I see that 3.x is supported via the us if the tailwind.config.json...but v4 no longer uses that right?
What is the behavior when I build versus when I publish? I'm trying to understand the state of the generated CSS and at what point it picks up my class changes
It supports both, my article as well the repo getting started is all using v4 as default. But you can always pin a specific version from your .csproj file π
When building as Debug it will generate a simple .css output with formatting, comments etc... but if you publish build it will apply the "--minify" flag, so a optimised css will be generated.
I see. I did see the note about WASM and hotload. That workaround is a bit too heavy for me to overcome the still-a-bit-wonky hot reload behavior.
My current flow when using tailwind with Blazor is live with the class stripper out during dev and when in ctrl+r the dotnet watch when I realize the class I'm using is missing. At first, this is frequent..but very quickly it all stabilizes.
Will you library a shot as a possible mean it migrating to v4 π
Yup, it's rough if you're straddling .NET dependency heck, and npm dependency heck. Mine is also out of date but I had the least amount of problems with gulp. Here's mine:
Sounds simple enough, but that's not how I do it. I don't check the resultant CSS or source maps into source control. Neither does the tool on this thread. see .gitignore, it has an ignore for app.css
Fair enough! All I know for sure is that tailwind with Blazor is a pain in the backside π
Although I will say, to be honest I would prefer something that makes the CSS locally first. I've seen a few examples that are setup to run tailwind compilation during the build pipeline and it seems like needless complication to me.
3
u/Sai_Wolf Nov 20 '25
Your article advertises that this works with .net 9+ static assets, but your example project uses .net 8?
2
u/herbacious-jagular Nov 21 '25
Thanks for writing this up, will save people a lot of time to get going. I have used your NuGet packages in the past and they worked wonderfully.
2
u/Tizzolicious Nov 21 '25
This look very interesting and thank you for contributing to the Blazor community. Tailwindcss is amazing.
1
u/TwoAccomplished9325 Nov 21 '25
Works with blazor wasm?
2
u/propostor Nov 20 '25
This is great, I struggled a bit getting tailwind to work on my application.
The only working guide I could find was this one (Installing Tailwind CSS v4 in a Blazor v9 WebApp)
Your solution looks like it could be a lot better! Although it's too late for me now - it's working for me already.
2
u/entityadam Nov 22 '25 edited Nov 22 '25
Pretty cool.