Noundry.Tailbreeze 1.2.2
by Tailbreeze Contributors
Tailbreeze
A .NET library for integrating Tailwind CSS into ASP.NET applications with zero Node.js dependency.
How It Works
Tailbreeze downloads the official Tailwind CSS standalone CLI from GitHub releases and manages it locally. During development, it runs the CLI in watch mode to automatically recompile CSS when your Razor/Blazor files change.
Your .cshtml/.razor files --> Tailwind CLI (watch mode) --> compiled CSS --> browser
Requirements
- .NET 8.0, 9.0, or 10.0
- Windows, macOS, or Linux (x64 or arm64)
- Internet connection (first run only, to download CLI)
Installation
dotnet add package Noundry.Tailbreeze
Quick Start
1. Add to Program.cs
using Tailbreeze.Extensions;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddRazorPages(); // or AddControllersWithViews(), AddRazorComponents()
builder.Services.AddTailbreeze();
var app = builder.Build();
app.UseStaticFiles();
app.UseTailbreeze();
app.MapRazorPages();
app.Run();
2. Add to your layout
Razor Pages / MVC (_Layout.cshtml):
@addTagHelper *, Tailbreeze
<!DOCTYPE html>
<html>
<head>
<tailwind-link />
</head>
<body>
@RenderBody()
</body>
</html>
Blazor (App.razor):
<link rel="stylesheet" href="/tailbreeze/app.css" />
Or use the TailwindLink component (requires @using Tailbreeze.Components in _Imports.razor):
<TailwindLink CdnFallback="true" />
3. Run
dotnet run
On first run, Tailbreeze will:
- Download the Tailwind CLI (~15MB) to
%LOCALAPPDATA%/Tailbreeze/cli/ - Create
Styles/app.csswith Tailwind directives - Create
tailwind.config.jswith auto-detected content paths - Start watch mode to compile CSS on file changes
Configuration
Via Code
builder.Services.AddTailbreeze(options =>
{
options.TailwindVersion = "4"; // "latest", "3", "4", or "3.4.17"
options.InputCssPath = "Styles/app.css";
options.OutputCssPath = "css/app.css";
options.ConfigPath = "tailwind.config.js";
options.EnableHotReload = true;
options.AutoInstallCli = true;
});
Via appsettings.json
{
"Tailbreeze": {
"TailwindVersion": "4",
"InputCssPath": "Styles/app.css",
"OutputCssPath": "css/app.css",
"EnableHotReload": true
}
}
builder.Services.AddTailbreeze(builder.Configuration);
Configuration Options
| Option | Default | Description |
|---|---|---|
TailwindVersion |
"latest" |
Version to use: "latest", "3", "4", or specific like "3.4.17" |
InputCssPath |
"Styles/app.css" |
Source CSS file (relative to project root) |
OutputCssPath |
"css/app.css" |
Output CSS file (relative to wwwroot) |
ConfigPath |
"tailwind.config.js" |
Tailwind config file path |
EnableHotReload |
true |
Enable watch mode in development |
MinifyCss |
null |
Minify CSS output (default: false in dev, true in production) |
AutoInstallCli |
true |
Auto-download CLI if missing |
ServePath |
"/tailbreeze/app.css" |
URL path for serving CSS |
ServeViaMiddleware |
true |
Serve CSS through middleware |
UseCdnFallback |
null |
Fall back to CDN if CLI fails (default: true in dev) |
CliDownloadUrl |
null |
Custom URL for CLI download (for mirrors/firewalls) |
ContentPaths |
[] |
Custom content paths (auto-detected if empty) |
AdditionalArguments |
null |
Additional arguments to pass to Tailwind CLI |
CliStartupTimeoutSeconds |
60 |
Timeout for CLI startup in seconds (minimum: 10) |
Version Support
| TailwindVersion | Downloads | CSS Syntax |
|---|---|---|
"latest" |
Latest stable release from GitHub | v4 (@import "tailwindcss") |
"4" |
Latest v4.x stable | v4 (@import "tailwindcss") |
"3" |
v3.4.17 (LTS) | v3 (@tailwind base/components/utilities) |
"3.4.17" |
Exact version | v3 |
"4.0.0" |
Exact version | v4 |
How Files Are Generated
Input CSS (Styles/app.css)
Tailwind v4:
@import "tailwindcss";
Tailwind v3:
@tailwind base;
@tailwind components;
@tailwind utilities;
Config File (tailwind.config.js)
Tailwind v4:
export default {
content: [
"./Pages/**/*.{cshtml,razor}",
"./Views/**/*.cshtml",
"./Components/**/*.{cshtml,razor}"
],
}
Tailwind v3:
module.exports = {
content: [
"./Pages/**/*.{cshtml,razor}",
"./Views/**/*.cshtml",
"./Components/**/*.{cshtml,razor}"
],
theme: {
extend: {},
},
plugins: [],
}
Custom Download URL
For corporate environments with restricted internet access:
{
"Tailbreeze": {
"CliDownloadUrl": "https://internal-mirror.company.com/tailwindcss-{os}-{arch}{extension}"
}
}
Placeholders:
{os}-windows,linux, ormacos{arch}-x64orarm64{version}- The configured version{extension}-.exeon Windows, empty otherwise
CLI Storage Location
The Tailwind CLI is downloaded once and cached at:
- Windows:
%LOCALAPPDATA%\Tailbreeze\cli\{version}\tailwindcss.exe - macOS/Linux:
~/.local/share/Tailbreeze/cli/{version}/tailwindcss
Production Builds
In production, the CSS is compiled once during publish. The watch mode only runs in Development environment.
For MSBuild integration (compile during dotnet publish), add the Noundry.Tailbreeze.Build package:
dotnet add package Noundry.Tailbreeze.Build
Troubleshooting
CSS not updating
- Check the console for Tailwind CLI output
- Verify
Styles/app.cssexists - Check
tailwind.config.jshas correct content paths
CLI download fails
- Check internet connectivity
- Try setting a custom
CliDownloadUrlto a mirror - Manually download from https://github.com/tailwindlabs/tailwindcss/releases
Classes not being detected
- Check
tailwind.config.jscontent paths include your file extensions - Ensure you're using complete class names (not string concatenation)
Architecture
src/Tailbreeze/
├── Extensions/
│ ├── ServiceCollectionExtensions.cs # AddTailbreeze()
│ └── ApplicationBuilderExtensions.cs # UseTailbreeze()
├── Services/
│ ├── ITailwindCliService.cs # CLI management interface
│ ├── TailwindCliService.cs # Downloads and executes CLI
│ └── TailwindHostedService.cs # Runs watch mode in dev
├── Middleware/
│ └── TailwindMiddleware.cs # Serves compiled CSS
├── TagHelpers/
│ └── TailwindLinkTagHelper.cs # <tailwind-link />
├── Components/
│ └── TailwindLink.razor # Blazor component
├── TailbreezeOptions.cs # Configuration
└── TailwindVersion.cs # Version parsing
License
MIT License - see LICENSE file.
Inspired by tailwind-dotnet by Kalleby Santos.
.NET 8.0
- Microsoft.Extensions.FileProviders.Physical (>= 9.0.0)
- Microsoft.Extensions.Hosting.Abstractions (>= 9.0.0)
- Microsoft.Extensions.Http (>= 9.0.0)
- Microsoft.Extensions.Http.Polly (>= 9.0.0)
.NET 9.0
- Microsoft.Extensions.Http.Polly (>= 9.0.0)
.NET 10.0
- Microsoft.Extensions.Http.Polly (>= 9.0.0)
No packages depend on Noundry.Tailbreeze.
See CHANGELOG.md for release notes.
Info
- Last updated 17 days ago
- License
- Download package
Statistics
- Total Downloads
- 29
- Current Version Downloads
- 12
Authors
Tailbreeze Contributors