Skip to content

Commit

Permalink
feat/breaking: Tailwind CSS v4 support (#7)
Browse files Browse the repository at this point in the history
* add support for transform-style

* feat: add support for new rotate utilities

* feat: add perspective utilities

* feat: add perspective-origin utilities

* feat: add linear gradient angles

* feat: add radial and conic gradients

* feat: add inset-shadow and inset-ring utilities

* feat: add field-sizing utilities

* feat: add color-scheme utilities

* feat: add font-stretch utilities

* feat: add renamed utilities and mark deprecated but still supported classes

* feat: add support for arbitrary custom properties (CSS variables) and re-achitect TwMergeConfig

* feat: add support for important modifier at the end of base class name

* feat: remove configurable separator

* feat: add support for new prefix syntax

* test: add test case for arbitrary variant without & symbol

* feat: add OrderSensitiveModifiers

* build(deps): add compatibility with .NET 9

* refactor: use StringBuilder for CSS classes concatenation

* test: add test for modifiers order

* docs: create limitations.md

* docs: create README.md

* docs: create what-is-it-for.md

* docs: create api-reference.md

* docs: create configuration.md

* docs: update features.md

* chore: update README.md

* ci(build-test): add .net9 compatibility

* ci(nuget-publish): add .net9 compatibility
  • Loading branch information
desmondinho authored Feb 24, 2025
1 parent 836cd41 commit 923fc3c
Show file tree
Hide file tree
Showing 29 changed files with 3,512 additions and 2,380 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
dotnet-version: |
8.0.x
9.0.x
- name: Restore dependencies
run: dotnet restore
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/nuget-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
dotnet-version: |
8.0.x
9.0.x
- name: Build
run: dotnet build -c Release
Expand Down
54 changes: 10 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,53 +7,19 @@

# tailwind-merge-dotnet

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

- Supports Tailwind v3.4
- Thread-safe LRU caching
- Supports Tailwind CSS v4 (if you use Tailwind v3, use tailwind-merge-dotnet v0.3.0)
- Thread-safe LRU caching
- Compatible with .NET 8 and 9

## Prerequisites
## Get Started

| .NET SDK | Support |
| :--------------------------------------------------------: | :----------------: |
| [.NET 8](https://dotnet.microsoft.com/download/dotnet/8.0) | :heavy_check_mark: |

## Usage

Register the service in the DI container:

```csharp
// 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:

```razor
@* 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]" *@
```

```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]"
```
- [What is it for](./what-is-it-for.md)
- [Features](./features.md)
- [Limitations](./limitations.md)
- [Configuration](./configuration.md)
- [API reference](./api-reference.md)

## Contributing

Expand Down
32 changes: 32 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<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 service to efficiently merge [Tailwind CSS](https://tailwindcss.com) classes in C# without style conflicts.

- Supports Tailwind CSS v4 (if you use Tailwind v3, use tailwind-merge-dotnet v0.3.0)
- Thread-safe LRU caching
- Compatible with .NET 8 and 9

## Get Started

- [What is it for](./what-is-it-for.md)
- [Features](./features.md)
- [Limitations](./limitations.md)
- [Configuration](./configuration.md)
- [API reference](./api-reference.md)

## Contributing

Contributions are always welcome!

See [CONTRIBUTING.md](CONTRIBUTING.md) for ways to get started. Please adhere to this project's [CODE_OF_CONDUCT](CODE_OF_CONDUCT.md).

## Acknowledgements 🙏

This project is a C# adaptation of [tailwind-merge](https://github.com/dcastil/tailwind-merge) originally developed by [dcastil](https://github.com/dcastil).
Loading

0 comments on commit 923fc3c

Please sign in to comment.