to-class
v1.4.1
Published
Build a string of conditional, deduplicated classNames.
Downloads
5
Readme
to-class
Builds a string of conditional, deduplicated classNames using whatever you can throw at it.
# npm
npm install to-class
# yarn
yarn add to-class
Usage
import toClass from 'to-class';
toClass('foo', 'bar', 'foo'); // => 'foo bar'
toClass(['foo', 'bar', false]); // => 'foo bar'
toClass('foo', {bar: true}); // => 'foo bar'
toClass({foo: true}, {bar: true}); // => 'foo bar'
toClass({foo: true, bar: false}); // => 'foo'
toClass({foo: true, bar: true}, ['bar', 'baz', ['foo']], 'foo'); // => 'foo bar baz'
Polyfill
If you need to support browsers <= IE11 you can import the polyfilled version.
import toClass from 'to-class/polyfill';