An open API service indexing awesome lists of open source software.

https://github.com/macklinu/cx

A utility for creating className strings
https://github.com/macklinu/cx

classnames clsx react tailwind-merge

Last synced: 5 months ago
JSON representation

A utility for creating className strings

Awesome Lists containing this project

README

          

# cx

> A utility for creating className strings

## Installation

```sh
pnpm add @macklinu/cx
```

## Usage

This is a combination of two libraries that I always use with Tailwind:

- [clsx](https://github.com/lukeed/clsx)
- [tailwind-merge](https://github.com/dcastil/tailwind-merge)

```ts
import { cx } from '@macklinu/cx'

cx('foo', 'bar') // 'foo bar'

// say state === 'loading'
cx('bg-red', 'text-white', state === 'loading' && 'is-loading') // 'bg-red text-white is-loading'

cx() // ''
```