1.3.0 • Published 2 months ago

@cdoman/tw v1.3.0

Weekly downloads
-
License
ISC
Repository
-
Last release
2 months ago

Tee Double U

A simple support library for Tailwind CSS. It makes using twMerge slightly more syntactically concise.

Usage

import { tw, is, TW } from "@cdoman/tw";

const otherClasses: string[] = ["other-classname", "color-emerald-500"];

const conditionalClasses: TW = is(disabled, "brightness-75 opacity-50");

const traditionalConditionalClass: string = loading ? "animate-pulse" : "";

const myStyles: TW = tw(
    "border border-solid border-red-500",
    "rounded-md",
    new TW("text-xl"),
    tw("shadow-lg"),
    conditionalClasses,
    traditionalConditionalClass,
    ...otherClassNames
);

const twClassNames = myStyles.tw; // "border border-solid border-red-500 rounded-md..."

Documentation

Classes

Functions

tw(classes) ⇒ TW

Creates a new TW instance with the given classes. If passed a TW instance, it will automatically call arg.tw on the object and add the result to the new instance.

Kind: global function
Returns: TW - A new TW instance with the compiled classes.

ParamTypeDescription
classesTWArgumentsA list of strings, TW instances, or undefined values.

is(condition, classes) ⇒

Creates a new TW instance with the given classes if the condition is true, otherwise returns undefined. This is a more concise version of condition ? tw(...classes) : undefined.

Kind: global function
Returns: A TW instance with the compiled classes if the condition is true, otherwise undefined.

ParamTypeDescription
conditionbooleanThe condition to check.
classesTWArgumentsA list of strings, TW instances, or undefined values to be applied.
1.3.0

2 months ago

1.2.0

4 months ago

1.2.1

4 months ago

1.1.0

4 months ago

1.0.1

4 months ago

1.0.0

4 months ago