@fvilers/cls
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

@fvilers/cls

An helper function for constructing className strings conditionally

Installation

npm install @fvilers/cls

or

yarn add @fvilers/cls

ECMAScript module

Starting with version 2.0.0, this library will be published as an ECMAScript module.

Usage

import cls from "@fvilers/cls";

// Strings (variadic)
cls("foo", true && "bar", "baz");
// It will output: 'foo bar baz'

// Objects
cls({ foo: true, bar: false, baz: isTrue() });
// It will output: 'foo baz'

// Objects (variadic)
cls({ foo: true }, { bar: false }, null, { "--foobar": "hello" });
// It will output: 'foo --foobar'

// Arrays
cls(["foo", 0, false, "bar"]);
// It will output: 'foo bar'

// Arrays (variadic)
cls(["foo"], ["", 0, false, "bar"], [["baz", [["hello"], "there"]]]);
// It will output: 'foo bar baz hello there'

// Kitchen sink (with nesting)
cls(
  "foo",
  [1 && "bar", { baz: false, bat: null }, ["hello", ["world"]]],
  "cya"
);
// It will output: 'foo bar hello world cya'

Package Sidebar

Install

npm i @fvilers/cls

Weekly Downloads

2

Version

2.0.0

License

MIT

Unpacked Size

12.6 kB

Total Files

9

Last publish

Collaborators

  • fvilers