@macklinu/cx

A utility for creating className strings

Usage no npm install needed!

<script type="module">
  import macklinuCx from 'https://cdn.skypack.dev/@macklinu/cx';
</script>

README

cx

A utility for creating className strings

Installation

yarn add @macklinu/cx

Usage

This is a simplified version of classnames, where any truthy string argument to the cx() function will be turned into a class string.

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() // ''