Zero-config Tailwind CSS v4 integration for Blazor. No Node.js, no npm — just dotnet add package and go.
dotnet new install TailwindBlazor.Templates
dotnet new blazor-tailwind -n MyApp
cd MyApp && dotnet runEverything is pre-configured — Tailwind CSS, the entry point, the stylesheet link, and UseTailwind().
dotnet add package TailwindBlazor/* Styles/app.css */
@import "tailwindcss";// Program.cs
using TailwindBlazor;
var builder = WebApplication.CreateBuilder(args);
builder.UseTailwind();<!-- App.razor or _Host.cshtml -->
<link rel="stylesheet" href="css/tailwind.css" /><h1 class="text-3xl font-bold text-gray-900">Hello, TailwindBlazor!</h1>Tailwind CSS requires a CLI to scan your files and generate CSS. In JavaScript projects, npm handles this. In .NET, there's no npm. TailwindBlazor bridges this gap by:
- Auto-downloading the standalone Tailwind CLI binary (no Node.js required)
- Integrating with MSBuild so CSS is generated on every build
- Running watch mode during development via an
IHostedService - Caching the CLI at
~/.tailwindblazor/cli/(shared across projects)
| Feature | Description |
|---|---|
| Auto CLI management | Downloads the correct binary for your OS/arch automatically |
| MSBuild integration | CSS compiles at build time, minifies in Release |
| Watch mode | --watch runs during development for instant rebuilds |
| Zero config | Sensible defaults, everything overridable |
| Multi-platform | Windows x64, macOS x64/ARM64, Linux x64/ARM64 |
TailwindBlazor works with zero configuration. Override defaults when needed:
<PropertyGroup>
<TailwindVersion>4.1.18</TailwindVersion>
<TailwindInputFile>Styles/app.css</TailwindInputFile>
<TailwindOutputFile>wwwroot/css/tailwind.css</TailwindOutputFile>
<TailwindEnabled>true</TailwindEnabled>
<TailwindMinify>false</TailwindMinify>
</PropertyGroup>builder.UseTailwind(options =>
{
options.InputFile = "Styles/app.css";
options.OutputFile = "wwwroot/css/tailwind.css";
options.CliPath = "/custom/path/to/tailwindcss";
options.TailwindVersion = "4.1.18";
});{
"Tailwind": {
"InputFile": "Styles/app.css",
"OutputFile": "wwwroot/css/tailwind.css",
"TailwindVersion": "4.1.18"
}
}Build time — MSBuild targets run before compilation:
- Detect OS and architecture
- Download Tailwind CLI to
~/.tailwindblazor/cli/<version>/(cached) - Run
tailwindcss -i <input> -o <output> - Minify automatically in Release mode
Dev time — The hosted service (when ASPNETCORE_ENVIRONMENT=Development):
- Ensure CLI is downloaded
- Start
tailwindcss --watchas a background process - Stream logs to
ILogger - Kill the process on shutdown
MSBuild targets and the hosted service work independently. You get CSS generation even without calling
UseTailwind().
using TailwindBlazor;
var builder = WebApplication.CreateBuilder(args);
builder.UseTailwind();
builder.Services.AddRazorComponents()
.AddInteractiveServerComponents();
var app = builder.Build();
app.UseAntiforgery();
app.MapStaticAssets();
app.MapRazorComponents<App>()
.AddInteractiveServerRenderMode();
app.Run();builder.UseTailwind(o => o.TailwindVersion = "4.0.0");builder.UseTailwind(o => o.CliPath = "/usr/local/bin/tailwindcss");dotnet build -p:TailwindEnabled=false| Don't | Do Instead |
|---|---|
| Install Node.js/npm for Tailwind | Use TailwindBlazor — it downloads the standalone CLI |
Create tailwind.config.js |
Tailwind v4 detects content files automatically |
| Manually download the CLI | Let TailwindBlazor manage it (or set CliPath once) |
Run tailwindcss --watch manually |
Call builder.UseTailwind() — the hosted service handles it |
| OS | Architecture |
|---|---|
| Windows | x64 |
| macOS | x64, ARM64 |
| Linux | x64, ARM64 |
| Problem | Solution |
|---|---|
| CLI download fails | Check firewall; set CliPath to a manually downloaded binary |
| CSS is empty | Ensure .razor files are in the project directory |
| Watch mode not starting | Verify ASPNETCORE_ENVIRONMENT=Development and UseTailwind() is called |
| Slow first build | CLI downloads once per version; subsequent builds are fast |