Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
desmondinho authored May 9, 2024
1 parent dd997cb commit cb83943
Showing 1 changed file with 41 additions and 1 deletion.
42 changes: 41 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,44 @@

A utility to efficiently merge [Tailwind CSS](https://tailwindcss.com) classes in C# without style conflicts.

- Supports Tailwind v3.4
- Supports Tailwind v3.3 up to v3.4

## Acknowledgements 🙏

This project is a complete reimplementation of [tailwind-merge](https://github.com/dcastil/tailwind-merge/tree/main) which was originally developed by [dcastil](https://github.com/dcastil).

This C# version has been developed to provide the same functionality in a different programming environment, catering to the needs of the .NET community.

## Usage

```csharp
// Program.cs
using TailwindMerge.Extensions;

var builder = WebApplication.CreateBuilder( args );

// Add service to the container
builder.Services.AddTailwindMerge();
```

---

Inject the registered service into the view/component:
```razor
@* Page.(razor/cshtml) *@
@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]" *@
```

```csharp
// 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]"
```

0 comments on commit cb83943

Please sign in to comment.