Skip to content

Instantly share code, notes, and snippets.

@yairEO
Last active October 22, 2020 10:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yairEO/105b10b0f13b8f33268ed5feb55108f1 to your computer and use it in GitHub Desktop.
Save yairEO/105b10b0f13b8f33268ed5feb55108f1 to your computer and use it in GitHub Desktop.
conditional multiple class names
const cx = (...list) => list.filter(Boolean).join(' ')
@yairEO
Copy link
Author

yairEO commented Oct 22, 2020

https://stackoverflow.com/a/64076688/104380

Example with React

<div className={cx('foo', condition && 'bar')} />

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment