conditional-classnames.js
v1.0.3
Published
Helper function setting conditional classnames on elements
Downloads
7
Maintainers
Readme
conditional-classnames.js
Helper function adding one or more classnames to an element depending on the result of the condition.
Installation
$ npm install --save conditional-classnames.js
Example
import 'conditional-classnames.js';
// Add bar when result is higher than 10. Otherwise remove it.
const foo = document.getElementById('#foo');
const result = (Math.random() * 10) > 10;
foo.classlist.bool('bar', result);