cxu
v0.0.2
Published
a fast and tiny classnames utility
Downloads
6
Readme
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.