One Spaces
A tiny module for making className 😎
Installation
npm (commonjs)
npm install one-spaces
browser (iife)
Please download this file.
And embed script tag in your document.
<script src="./dist/one-spaces.js"></script>
Example
VanillaJS
var el = document.getElementById('my-element');
el.className = OneSpaces('cls1', 'cls2', 'cls3');
el.className = OneSpaces(['cls1', 'cls2'], ['cls3']);
el.className = OneSpaces('cls1', null, 'cls2', false && 'none', true && 'cls3');
el.className = OneSpaces(['cls1', 'cls2'], null, 'cls3');
React (jsx)
import spaces from 'one-spaces';
export default () => {
return (
<div className={spaces(['cls1', 'cls2'], null, 'cls3')}>
<span>Hello React!</span>
</div>
);
};
Angular & Vue
Angular and Vue have their own system for className.
Of course you can use this module with them but not recommended.