0.0.2 • Published 1 year ago

cxu v0.0.2

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

cxµ

npmv0.0.2
size137b minzipped
dependencieszero
licenseMIT

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.

0.0.2

1 year ago

0.0.1

1 year ago