TailwindBlazor integrates Tailwind CSS v4 into your Blazor app with zero external dependencies. No Node.js, no npm, no manual CLI installs.
$ dotnet new install TailwindBlazor.Templates
$ dotnet new blazor-tailwind -n MyApp
$ cd MyApp && dotnet run
Everything pre-configured. Skip to Configuration to customize.
Options: --interactivity server|webassembly|auto|none and --Framework net8.0|net9.0|net10.0
$ dotnet add package TailwindBlazor
Create a file at Styles/app.css in your project root:
@import "tailwindcss";
Add one line to your Program.cs:
using TailwindBlazor;
var builder = WebApplication.CreateBuilder(args);
builder.UseTailwind();
Add the stylesheet link in your App.razor or _Host.cshtml:
<link rel="stylesheet" href="css/tailwind.css" />
<h1 class="text-3xl font-bold text-gray-900">
Hello, TailwindBlazor!
</h1>
TailwindBlazor works out of the box with sensible defaults. Everything is overridable through MSBuild properties, C# options, or appsettings.json.
Set these in your .csproj to control build-time behavior:
<PropertyGroup>
<TailwindVersion>4.1.18</TailwindVersion>
<TailwindInputFile>Styles/app.css</TailwindInputFile>
<TailwindOutputFile>wwwroot/css/tailwind.css</TailwindOutputFile>
<TailwindEnabled>true</TailwindEnabled>
<TailwindMinify>false</TailwindMinify>
</PropertyGroup>
| Property | Default | Description |
|---|---|---|
| TailwindVersion | 4.1.18 | Tailwind CLI version to download |
| TailwindInputFile | Styles/app.css | CSS entry point relative to project root |
| TailwindOutputFile | wwwroot/css/tailwind.css | Generated CSS output path |
| TailwindEnabled | true | Enable/disable the build target |
| TailwindMinify | $(Optimize) | Minify output (auto in Release) |
Configure the runtime hosted service via the UseTailwind overload:
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";
});
Options are also bound from the Tailwind configuration section:
{
"Tailwind": {
"InputFile": "Styles/app.css",
"OutputFile": "wwwroot/css/tailwind.css",
"TailwindVersion": "4.1.18"
}
}
MSBuild targets run before compilation:
~/.tailwindblazor/cli/<version>/ (cached — only on first build)tailwindcss -i <input> -o <output> to generate the CSS--minify is applied automaticallyWhen the environment is Development, the hosted service:
tailwindcss --watch as a background processILogger
Build vs Runtime:
MSBuild targets handle CSS generation for dotnet build and
dotnet publish.
The hosted service adds watch mode for live development. Both mechanisms work independently — you get CSS generation
even without calling UseTailwind().
The correct CLI binary is resolved automatically based on your OS and CPU architecture.
| Operating System | Architecture | CLI Binary |
|---|---|---|
| Windows | x64 | tailwindcss-windows-x64.exe |
| macOS | x64 | tailwindcss-macos-x64 |
| macOS | ARM64 | tailwindcss-macos-arm64 |
| Linux | x64 | tailwindcss-linux-x64 |
| Linux | ARM64 | tailwindcss-linux-arm64 |
Check your internet connection and firewall settings. The CLI is downloaded from
github.com/tailwindlabs/tailwindcss/releases.
You can also download it manually and set TailwindCliPath in your .csproj
or options.CliPath in C#.
Tailwind v4 scans your project files automatically. Make sure your .razor files
are in the project directory. If using a non-standard structure, check that the CLI can find your content files.
The hosted service only runs when ASPNETCORE_ENVIRONMENT=Development.
Make sure you're running with dotnet watch or
dotnet run in development mode.
Pass dotnet build -p:TailwindEnabled=false
to skip CSS generation entirely.