Table of Contents

Class TwClassMergeOptions

Namespace
TwBlazor.Configuration
Assembly
TwBlazor.dll

Controls how conflicting Tailwind classes are merged when a component builds its class attribute.

public sealed class TwClassMergeOptions
Inheritance
TwClassMergeOptions
Inherited Members

Remarks

Optional. Out of the box the last conflicting utility wins (a consumer's px-2 replaces a theme's px-4) and classes that are not Tailwind utilities are left alone. The configuration is applied when AddTwBlazor is called and is shared by the whole application.

Constructors

TwClassMergeOptions()

public TwClassMergeOptions()

Fields

DefaultCacheSize

The number of merge results cached unless CacheSize is set.

public const int DefaultCacheSize = 2048

Field Value

int

Properties

CacheSize

Gets or sets how many merge results are cached, keyed on the whole class string. Defaults to DefaultCacheSize. When the cache is full it is emptied and starts again. Zero or less turns caching off.

public int CacheSize { get; set; }

Property Value

int

Enabled

Gets or sets whether conflicting classes are merged. Defaults to true. When false every class is rendered as written.

public bool Enabled { get; set; }

Property Value

bool

Groups

Gets the custom class groups, checked before the built-in Tailwind groups. Use these for your own utilities (for example @utility classes) or to change what a built-in group conflicts with.

public IList<TwClassGroup> Groups { get; }

Property Value

IList<TwClassGroup>

OrderSensitiveVariants

Gets the extra variants whose position among the other variants matters, added to the built-in ones such as before and *.

public IList<string> OrderSensitiveVariants { get; }

Property Value

IList<string>

Remarks

Add a variant you define with @custom-variant when it changes which element is styled, the way a pseudo-element does. hover:my-variant:px-2 and my-variant:hover:px-2 are then kept apart instead of being treated as the same class. Write each one without its colon.

Prefix

Gets or sets the prefix of your Tailwind build, without its colon: tw for classes written as tw:px-4. Defaults to null, for a build with no prefix.

public string? Prefix { get; set; }

Property Value

string

Remarks

Set it to the value given to prefix(...) in your stylesheet. Only classes that start with the prefix are then treated as Tailwind utilities. Every other class is left alone, even one named like a utility (hidden, container), since in a prefixed build such a class comes from somewhere else. Prefixed classes are merged with each other whether or not this is set.