mymergeclassnames
v1.0.1
Published
Merges class names, whatever the format. Can be a single class, a string with multiple classes separated with space, an array of classes
Downloads
1
Maintainers
Readme
mergeClassNames
Merges class names, whatever the format. Can be a single class, a string with multiple classes separated with space, an array of classes Removes duplicates
Install
# Install using npm
npm install @maximusft/[email protected] --save
Use
import mergeClassNames from 'mergeclassnames';
export default (props) => {
const { someClassNames } = props;
/* Expample:
someClassNames = ['a', false, 'b', 'c', null, ['d', null], () => {}, 'e', undefined, 'c', ['f', false]];
*/
return (
<div className="my-component">
<SomeElement
className={mergeClassNames('someHardCoreClass', someClassNames)}
/>
{/*
Output: <SomeElement className="someHardCoreClass a b c d e f" />
*/}
</div>
);
}
}