VOOZH about

URL: https://www.nuget.org/packages/TailwindVariants.NET/

⇱ NuGet Gallery | TailwindVariants.NET 0.2.9




👁 Image
TailwindVariants.NET 0.2.9

dotnet add package TailwindVariants.NET --version 0.2.9
 
 
NuGet\Install-Package TailwindVariants.NET -Version 0.2.9
 
 
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="TailwindVariants.NET" Version="0.2.9" />
 
 
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TailwindVariants.NET" Version="0.2.9" />
 
Directory.Packages.props
<PackageReference Include="TailwindVariants.NET" />
 
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add TailwindVariants.NET --version 0.2.9
 
 
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: TailwindVariants.NET, 0.2.9"
 
 
#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.
#:package TailwindVariants.NET@0.2.9
 
 
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=TailwindVariants.NET&version=0.2.9
 
Install as a Cake Addin
#tool nuget:?package=TailwindVariants.NET&version=0.2.9
 
Install as a Cake Tool
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

TailwindVariants.NET

TailwindVariants.NET is a strongly typed Blazor library for managing TailwindCSS variants and slot-based styling.

⚠️ This package is not related to tailwind-variants — it only draws inspiration from its ideas and applies them to a strongly typed, Blazor-first API.


✨ Features

  • Strongly typed variant definitions for Blazor components (with or without slots).
  • Default classes for slots + variants, and slot-aware compound variants.
  • Generated slot accessors for convenient, strongly typed access to slot classes (b => b.Base automatically wrapped).
  • Simple API builder (Variants<TOwner, TSlots>).
  • Integration with TailwindMerge.NET to resolve conflicts between Tailwind classes.
  • Lightweight, no JS runtime dependencies (pure Blazor/C#).
  • Incremental source generator (TailwindVariants.SourceGenerators) for generating strongly typed slot accessors.
  • Supports .NET 8, .NET 9, and .NET Standard 2.0 (source generator only).
  • Works seamlessly in Blazor projects (Server, WebAssembly, Hybrid).

Installation

Install from NuGet:

dotnet add package TailwindVariants.NET

To enable automatic generation of slot accessors, it's included an analyzer with the main package.

The package supports:

  • >= .NET 8

Quick Example

using TailwindVariants.NET;

public partial class Button : ISlottable<Button.Slots>
{
 private static readonly TvDescriptor<Button, Slots> _button = new
 (
 @base: "font-semibold border rounded",
 variants: new()
 {
 [b => b.Variant] = new Variant<Variants, Slots>()
 {
 [Variants.Primary] = "bg-blue-500 text-white border-transparent",
 [Variants.Secondary] = "bg-white text-gray-800 border-gray-400",
 },
 [b => b.Size] = new Variant<Sizes, Slots>()
 {
 [Sizes.Small] = "text-sm py-1 px-2",
 [Sizes.Medium] = "text-base py-2 px-4",
 },
 }
 compoundVariants: 
 [
 new(b => b.Variant == Variants.Primary && !b.Disabled)
 {
 Class = "hover:bg-blue-600"
 }
 ]
 );

 protected override void OnParametersSet()
 {
 _slots = Tv.Invoke(this, _button);
 }

 protected override TvDescriptor<Button, Slots> GetDescriptor() => _button;

 public sealed partial class Slots : ISlots
 {
 public string? Base { get; set; }
 }

 // ... enums omitted for brevity ...
}

In the component:

@inherits TwComponentBase<Button, Button.Slots>

<button class="@_slots.GetBase()" disabled="@Disabled">
 @ChildContent
</button>

@code
{
 [Parameter]
 public RenderFragment? ChildContent { get; set; }
 
 [Parameter]
 public Slots? Classes { get; set; }
 
 [Parameter]
 public Variants Variant { get; set; }
 
 [Parameter]
 public Sizes Size { get; set; }
 
 [Parameter]
 public bool Disabled { get; set; }
}
Slot Access

With generated slot accessors (via the source generator), you no longer need to write _slots[b => b.Avatar] manually. You can use strongly typed properties:

<img class="@_slots.GetBase()" src="avatar.png" />
<p class="@_slots.GetDescription()">Description text</p>

This is enabled by the incremental source generator (TailwindVariants.SourceGenerators), which automatically generates accessors for each component that implements ISlots.


Documentation

Go to the documentation for the full explanation of the example


Acknowledgements / Credits

Special thanks to the authors of the following projects that are either used or inspired this work:

Check out those projects for more tools and context.


Contributing

Contributions are always welcome!

Please follow our .

Please adhere to this project's .


License

MIT — see the LICENSE file in the repository.


Repository & Issues

If you encounter problems or have feature requests, open an issue on the GitHub repository.

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

NuGet packages (1)

Showing the top 1 NuGet packages that depend on TailwindVariants.NET:

Package Downloads
RizzyUI

This package allows you to build applications quickly using the Rizzy library and this set of SSR only components.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.2.9 3,696 1/29/2026
0.2.8 405 11/21/2025
0.2.8-preview.1 185 11/5/2025
0.2.7 240 10/26/2025
0.2.7-preview.4 121 10/24/2025
0.2.7-preview.3 168 10/23/2025
0.2.7-preview.2 178 10/23/2025
0.2.7-preview.1 297 10/20/2025
0.2.6 161 10/17/2025
0.2.5 168 10/17/2025
0.2.4 380 10/16/2025
0.2.3 214 10/16/2025
0.2.2 214 10/15/2025
0.2.1 221 10/14/2025
0.2.0 218 10/14/2025
0.1.0 376 10/12/2025
0.0.6 172 10/11/2025
0.0.5 155 10/11/2025
0.0.4 163 10/10/2025
0.0.3 164 10/10/2025
Loading failed