cxu
TypeScript icon, indicating that this package has built-in type declarations

0.0.2 • Public • Published

cxµ

npm v0.0.2
size 137b minzipped
dependencies zero
license MIT

a fast and tiny classnames utility

for years i've been adding const cx = (...c) => c.filter(Boolean).join(' '); to my frontend repos to handle quick css class needs. in a bout of misplaced hyperfocus i wanted to try to make a "faster" version of this that was just as simple, functioned the exact same, and still remained relatively small. this is cxµ.

usage

script include

<script src="https://unpkg.com/cxu"></script>
function updateProfileCardStyles(condition) {
	profileCard.className = cx('profile-card', condition && 'active');
}

import

npm install cxu

import cx from 'cxu';

const App = ({ active }) => {
	return <div className={cx('profile-card', active && 'active')} />;
};

api

cxµ's cx works just like const cx = (...c) => c.filter(Boolean).join(' ');. its just significantly more performant. evaluate logic and return strings or falsey to build your classname string.

Package Sidebar

Install

npm i cxu

Weekly Downloads

1

Version

0.0.2

License

MIT

Unpacked Size

5.16 kB

Total Files

8

Last publish

Collaborators

  • merlis