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
- Host: GitHub
- URL: https://github.com/macklinu/cx
- Owner: macklinu
- License: mit
- Created: 2019-08-12T22:11:47.000Z (almost 7 years ago)
- Default Branch: main
- Last Pushed: 2025-01-13T15:49:28.000Z (over 1 year ago)
- Last Synced: 2025-09-19T10:46:37.902Z (10 months ago)
- Topics: classnames, clsx, react, tailwind-merge
- Language: TypeScript
- Homepage:
- Size: 202 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
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() // ''
```