TailwindMerge.NET
0.1.0-rc
See the version list below for details.
dotnet add package TailwindMerge.NET --version 0.1.0-rc
NuGet\Install-Package TailwindMerge.NET -Version 0.1.0-rc
<PackageReference Include="TailwindMerge.NET" Version="0.1.0-rc" />
<PackageVersion Include="TailwindMerge.NET" Version="0.1.0-rc" />
<PackageReference Include="TailwindMerge.NET" />
paket add TailwindMerge.NET --version 0.1.0-rc
#r "nuget: TailwindMerge.NET, 0.1.0-rc"
#:package TailwindMerge.NET@0.1.0-rc
#addin nuget:?package=TailwindMerge.NET&version=0.1.0-rc&prerelease
#tool nuget:?package=TailwindMerge.NET&version=0.1.0-rc&prerelease
<div align="center"> <br /> <a href="https://github.com/desmondinho/tailwind-merge-dotnet"> <img src="https://raw.githubusercontent.com/desmondinho/tailwind-merge-dotnet/HEAD/assets/logo.svg" alt="tailwind-merge-dotnet" height="150px" /> </a> </div>
tailwind-merge-dotnet
A utility to efficiently merge Tailwind CSS classes in C# without style conflicts.
- Supports Tailwind v3.4
- Thread-safe LRU caching
Prerequisites
| .NET SDK | Support |
|---|---|
| .NET 8 | ✔️ |
Usage
Register the service in the DI container:
// Program.cs
using TailwindMerge.Extensions;
var builder = WebApplication.CreateBuilder( args );
// Add TailwindMerge to the container
builder.Services.AddTailwindMerge();
Inject the service into component using one of the following approaches:
@* Page.razor *@
@inject TwMerge TwMerge
@TwMerge.Merge("px-2 py-1 bg-red hover:bg-dark-red", "p-3 bg-[#B91C1C]")
@* → "hover:bg-dark-red p-3 bg-[#B91C1C]" *@
// Page.razor.cs
[Inject] private TwMerge TwMerge {get; set; } = default!;
TwMerge.Merge("px-2 py-1 bg-red hover:bg-dark-red", "p-3 bg-[#B91C1C]")
// → "hover:bg-dark-red p-3 bg-[#B91C1C]"
Contributing
Contributions are always welcome!
See CONTRIBUTING.md for ways to get started. Please adhere to this project's CODE_OF_CONDUCT.
Acknowledgements 🙏
This project is a C# adaptation of tailwind-merge originally developed by dcastil.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.1)
- Planetarium.LruCacheNet (>= 1.2.0)
NuGet packages (11)
Showing the top 5 NuGet packages that depend on TailwindMerge.NET:
| Package | Downloads |
|---|---|
|
BlazorBlueprint.Components
Pre-styled Blazor components built with shadcn/ui design and Tailwind CSS. Beautiful defaults that you can customize to match your brand. |
|
|
LumexUI
🚀 A versatile Blazor UI library built using Tailwind CSS. |
|
|
Flowbite
Flowbite component library for ASP.NET Blazor 8.0, providing a comprehensive set of UI components styled with TailwindCSS. |
|
|
PureBlazor.Components
Tailwind based Blazor UI components |
|
|
TailwindVariants.NET
A Blazor library to manage TailwindCSS variants and slot-based styling with strongly typed APIs. |
GitHub repositories (2)
Showing the top 2 popular GitHub repositories that depend on TailwindMerge.NET:
| Repository | Stars |
|---|---|
|
LumexUI/lumexui
🚀 A versatile Blazor UI library built using Tailwind CSS.
|
|
|
blazorblueprintui/ui
A collection of accessible, headless primitives and beautifully-designed components for Blazor inspired by shadcn/ui.
|