Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I like to use a library called classnames. It lets you define dynamically-applied classes in a much more readable way.

https://www.npmjs.com/package/classnames



Another (smaller) alternative is clsx: https://www.npmjs.com/package/clsx


Another (even smaller) alternative is `.join`

`const classes = [some, classNames, here, foo ? 'foo' : ''].join(' ');`




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: