ReactJS

ReactJS: Handy className Generator

3 steps.

1. Install

$ npm i classnames --save-dev

2. Import

import classNames from 'classnames';

3. Use

<div className={classNames('foo')}></div>

// switch the bold part with any of below:
classNames('foo', 'bar'); // => 'foo bar' 
classNames('foo', { bar: true }); // => 'foo bar' 
classNames({ foo: true, bar: true }); // => 'foo bar'
Standard