Instantiates a new ClassNames Instance
Rest
...classes: AddInputValue[]default values to add
Private
classesStores the Classes in this Instance
Returns the number of values in this instance
Add a value to this instance.
CHAINABLE
Notes:
Rest
...inputValues: AddInputValue[]Conditionally Added Classes
new ClassNames().if(disabled === true, "bg-gray-100", "bg-sky-700").list();
this instance
The If Condition
Values to add if the Condition is True
Values to add of the Condition is False
Add Classes to Instance if a Pattern is found in the Instance
this instance
the Pattern or class to look for
values to be added if pattern is found
Add Classes to Instance if a Pattern is not found in the Instance
this instance
the Pattern or class to look for
values to be added if pattern is not found
Remove Classes to Instance if a Pattern is not found in the Instance
this instance
the Pattern or class to look for
values to be Removed if pattern is not found
Remove Classes to Instance if a Pattern is found in the Instance
this instance
the Pattern or class to look for
values to be Removed if pattern is found
Private
isCheck if the Provided Value is an Instance of ClassNames
if the value is an instance of ClassNames
Value to Check
Returns this instances values as a string.
<h1 classNames={ new ClassNames("text-xl").list() }>Hello World!</h1>
Rest
...inputValues: AddInputValue[]Private
makeRemove a value from this instance
Rest
...inputValues: RemoveInputValue[]Act like a Switch Case for Added Classes
Usage
new ClassNames<"success" | "danger">(["rounded text-white px-4 py-2"])
.switch(btnType, {
"success": "bg-emerald-700",
"danger": "bg-red-700"
}, "bg-sky-700")
this instance
Union of Expected Potential Values of onValue
The the Value to Switch On
Object Containing Possible Values and there Keys
Optional
defaultValue: ClassNameAddValueOptional Default Value
Static
addStatic accessor to add ClassNames
Shortcut Of new ClassNames().add(value)
an Instance of ClassNames
classes to add to new instance of ClassNames
Static
isGenerated using TypeDoc
A Class to help Manage Classes for Components