lukeed/clsxPublic

A tiny (239B) utility for constructing `className` strings conditionally.

v2.1.0

LUlukeed published a60db12Immutable

Release notes

## Features

- Add new `clsx/lite` submodule for `string`-only usage: 1a49142

_This is a **140b** version of `clsx` that is ideal for Tailwind and/or React contexts, which typically follow this `clsx` usage pattern:_

```js clsx('foo bar', props.maybe && 'conditional classes', props.className); ```

> **Important:** This `clsx/lite` module **ignores all non-string arguments** and is therefore not a 1:1 replacement for `clsx` itself!

```js import { clsx } from 'clsx'; import { clsx as lite } from 'clsx/lite';

// strings-only usage is identical clsx('foo', null, 'bar', true && 'baz'); //=> "foo bar baz" lite('foo', null, 'bar', true && 'baz'); //=> "foo bar baz"

// clsx/lite ignores all non-strings clsx('foo', { a: true, b: false, c: true }); //=> "foo a c" lite('foo', { a: true, b: false, c: true }); //=> "foo" ```

---

> **Full Changelog**: https://github.com/lukeed/clsx/compare/v2.0.1...v2.1.0

Attached at publication

## Features

- Add new `clsx/lite` submodule for `string`-only usage: 1a49142

_This is a **140b** version of `clsx` that is ideal for Tailwind and/or React contexts, which typically follow this `clsx` usage pattern:_

```js clsx('foo bar', props.maybe && 'conditional classes', props.className); ```

> **Important:** This `clsx/lite` module **ignores all non-string arguments** and is therefore not a 1:1 replacement for `clsx` itself!

```js import { clsx } from 'clsx'; import { clsx as lite } from 'clsx/lite';

// strings-only usage is identical clsx('foo', null, 'bar', true && 'baz'); //=> "foo bar baz" lite('foo', null, 'bar', true && 'baz'); //=> "foo bar baz"

// clsx/lite ignores all non-strings clsx('foo', { a: true, b: false, c: true }); //=> "foo a c" lite('foo', { a: true, b: false, c: true }); //=> "foo" ```

---

> **Full Changelog**: https://github.com/lukeed/clsx/compare/v2.0.1...v2.1.0

Assets 0
None were attached at publication.
No assets.

Shipped in this Release 0

None

Deployments 0

  • None

History 0

No Decisions yet.