Metaphor.Tailwind.Extensions.AspNetCore 0.0.0-alpha.0.20

This is a prerelease version of Metaphor.Tailwind.Extensions.AspNetCore.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package Metaphor.Tailwind.Extensions.AspNetCore --version 0.0.0-alpha.0.20
NuGet\Install-Package Metaphor.Tailwind.Extensions.AspNetCore -Version 0.0.0-alpha.0.20
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Metaphor.Tailwind.Extensions.AspNetCore" Version="0.0.0-alpha.0.20" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Metaphor.Tailwind.Extensions.AspNetCore --version 0.0.0-alpha.0.20
#r "nuget: Metaphor.Tailwind.Extensions.AspNetCore, 0.0.0-alpha.0.20"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Metaphor.Tailwind.Extensions.AspNetCore as a Cake Addin
#addin nuget:?package=Metaphor.Tailwind.Extensions.AspNetCore&version=0.0.0-alpha.0.20&prerelease

// Install Metaphor.Tailwind.Extensions.AspNetCore as a Cake Tool
#tool nuget:?package=Metaphor.Tailwind.Extensions.AspNetCore&version=0.0.0-alpha.0.20&prerelease

Disclaimer: This project is not affiliated with or supported by Tailwind Labs.

Use Tailwind's JIT mode with dotnet run and dotnet watch run

Makes it possible to use the new "Just In Time" builds for Tailwind (Tailwind 3+) with ASP.NET Core.

Works for Blazor WASM applications that are hosted via ASP.NET Core, and Blazor Server applications.

Note it doesn't work with Blazor WASM apps that aren't hosted via ASP.NET Core.


Create a new Hosted Blazor WASM, or Blazor Server project.

CD to the Client App's folder (if Blazor WASM) or Blazor Server App's folder.

Run these commands:

npm install -D tailwindcss cross-env
npx tailwindcss init

This will install Tailwind and the handy cross-env utility via NPM, then create a tailwind.config.js file.

Now update the tailwind.config.js file to include all your .razor and .cshtml files.

module.exports = {
  content: ["**/*.razor", "**/*.cshtml", "**/*.html"],
  theme: {
    extend: {},
  plugins: [],

Now you'll want to create the Tailwind input stylesheet. This is the stylesheet that Tailwind will then pick up and build.

Here's the minimum you'll need...


@tailwind base;
@tailwind components;
@tailwind utilities;

Finally, update your package.json file to add this script.

  "scripts": {
    "tailwind": "cross-env NODE_ENV=development ./node_modules/tailwindcss/lib/cli.js -i ./Styles/input.css -o ./wwwroot/css/output.css --watch"

Make sure .Styles/input.css is pointing to the css file you created in the last step. You can control where the resulting css file is created by specifying your own value for the -o parameter.

That takes care of the Tailwind setup, now we just need to make this run when you run your ASP.NET Core project during Development.

Make sure you switch to the Server App's folder if you're using Blazor WASM (hosted).

Run this command to install the Tailwind AspNetCore NuGet package.

dotnet add package Tailwind.Extensions.AspNetCore --version 1.0.0-beta2

Now head over to Program.cs and add this code before app.Run();

if (app.Environment.IsDevelopment())
    app.RunTailwind("tailwind", "./");

The second argument is the path to the folder containing your package.json file. If you're using Blazor WASM you'll probably need something like this...

if (app.Environment.IsDevelopment())
    app.RunTailwind("tailwind", "../Client/");

You'll also need to add this using statement:

using Tailwind;

Now, run dotnet watch run and try modifying your Razor components (using Tailwind's utility classes).

You should see logs indicating that tailwind has rebuilt the CSS stylesheet successfully.

Known Issues

If you use dotnet watch run to launch your application you'll likely find everything works as you'd expect: you can make changes to your razor files and see those changes reflected in the browser.

With Visual Studio the experience is somewhat more hit and miss. It looks like there is an issue whereby VS hot reload doesn't detect and apply changes to .css files when you have a Blazor WASM project hosted via ASP.NET Core.

There's an open Visual Studio feedback item about that here: Hot Reload For CSS Not Working With Blazor WebAssembly Hosted

Might be worth up-voting that if you're having difficulties.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.0.0-alpha.0.26 110 7/29/2023
0.0.0-alpha.0.25 80 7/29/2023
0.0.0-alpha.0.21 83 7/29/2023
0.0.0-alpha.0.20 77 7/29/2023