![]() |
VOOZH | about |
dotnet add package TailwindVariants.NET --version 0.2.9
NuGet\Install-Package TailwindVariants.NET -Version 0.2.9
<PackageReference Include="TailwindVariants.NET" Version="0.2.9" />
<PackageVersion Include="TailwindVariants.NET" Version="0.2.9" />Directory.Packages.props
<PackageReference Include="TailwindVariants.NET" />Project file
paket add TailwindVariants.NET --version 0.2.9
#r "nuget: TailwindVariants.NET, 0.2.9"
#:package TailwindVariants.NET@0.2.9
#addin nuget:?package=TailwindVariants.NET&version=0.2.9Install as a Cake Addin
#tool nuget:?package=TailwindVariants.NET&version=0.2.9Install as a Cake Tool
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.
b => b.Base automatically wrapped).Variants<TOwner, TSlots>).TailwindMerge.NET to resolve conflicts between Tailwind classes.TailwindVariants.SourceGenerators) for generating strongly typed slot accessors.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:
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; }
}
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.
Go to the documentation for the full explanation of the example
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.
Contributions are always welcome!
Please follow our .
Please adhere to this project's .
MIT — see the LICENSE file in the repository.
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. |
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. |
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 |