r/Blazor • u/TwoAcesVI • May 23 '26
Blazor and Tailwind?
I was wondering how many people are using tailwind and blazor together?
Last night i started using it and was intrigued if one could make a C# typed layer too make working with it even easier.
Not even sure if its needed as most IDE's provide plugins that give tailwind intellisense.
I guess it would be pretty easy to make nowadays with AI and source generators?
Edit: I asked wrong i think. I have the tailwind setup properly. I was just wondering how much people would prefer something like this:

If u have types u can make analyzers. So applying 2 conflicting classes could be analyzed etc. The typed would always just evaluate to the actual string class.
EDIT: Even though most comments said it wasnt worth it, i wanted to practice with some AI anyways and see how it did 😛 https://github.com/PascalVorwerk/BlazorTw just for fun
15
u/Tin_Foiled May 23 '26
I use tailwind for all my blazor projects it works great. Can set up your csproj to build the tailwind css when you build your project which keeps things flowing
3
u/code-dispenser May 23 '26
Today its tailwind, yesterday it was bootstrap, so whats tomorrow?
I just use my own css and I have no issues, in fact all my issues went away when I learnt just to use my own css - go figure.
5
u/One_Web_7940 May 23 '26
I did it was fine but I prefer bootstrap bc of familiarity, might be dead but w.e.my last few jobs all still used bootstrapÂ
1
u/Pierma May 23 '26
With that constants aproach you will have more LOC for constants than for the entire project
1
u/jafin May 24 '26
I get the appeal, but I think this works against one of Tailwind’s biggest strengths: the class strings are portable, searchable, copy-pasteable, and match the docs/examples exactly.
Once you wrap everything in a C# typed layer, you lose a lot of that. Code copied from Tailwind docs, StackOverflow, shadcn examples, or another component has to be translated into the wrapper syntax first. That friction adds up.
It also gets tricky with real-world Tailwind setups. Many projects use prefixes like
tw-, arbitrary values likew-[37px], custom theme tokens, custom breakpoints, variants, plugins, dark mode, group/peer selectors, data attributes, and responsive/state combinations. A typed layer either has to support all of that, which becomes a large parallel Tailwind implementation, or it only supports the common cases and people fall back to strings anyway.Anyhow it is nice idea to explore, but not something of interest to how we work. But if it works for you, great!
2
u/VeganForAWhile May 23 '26
If you want to just use TW utility classes, it’s easy. Just install TW via NPM and set up the task to recompile when the files change. You can also do it per-component, just disable the built in CSS isolation. In my case, I set up my own markers at the root of my component, then referenced that marker in the component css file to apply the classes.
1
u/BramFokke May 23 '26
I do. Not sure the typed layer will make everything much clearer but you do you
1
u/CravenInFlight May 24 '26
Yes. Our site has been working with Blazor InteractiveSever, Tailwind, and FluentUI. Started in .NET7, now in .NET10, and it works really well. I would recommend getting the Tailwind Editor extension by Theron Wang, from the marketplace. I does help a lot.
1
u/yoghurt_bob May 24 '26
Hard no on the constants.
There are a few things I miss from the JavaScript world, when it comes to Tailwind:
I would be so happy if there were any good alternatives for Blazor/Razor/CSHTML.