merge-class-names
A function that merges given class names, no matter their format: string with single or multiple class names or an array of class names. Filters out invalid class names as well.
Last updated 4 years ago by wojtekmaj .
MIT · Repository · Original npm
$ cnpm install merge-class-names 
SYNC missed versions from official npm registry.

npm downloads build dependencies dev dependencies tested with jest

Merge-Class-Names

A function that merges given class names, no matter their format. Filters out invalid class names as well.

tl;dr

  • Install by executing npm install merge-class-names or yarn add merge-class-names.
  • Import by adding import mergeClassNames from 'merge-class-names'.
  • Pass arguments to it. Forget.

Accepted formats

  • Strings with one or multiple class names: a, a b
  • Array of strings with one or multiple class names: ['a', 'b'], ['a b', 'c d'].

Examples

> mergeClassNames('a', 'b', 'c');
< 'a b c'

> mergeClassNames('a b', 'c d', 'e f');
< 'a b c d e f'

> mergeClassNames(['a', 'b'], ['c', 'd']);
< 'a b c d'

> mergeClassNames(['a b', 'c d'], ['e f', 'g h']);
< 'a b c d e f g h'

> mergeClassNames('a', 'b', falsyCondition && 'c');
< 'a b'

> mergeClassNames('a', 'b', 'c', null, ['d', null], () => {}, 'e', undefined);
< 'a b c d e'

License

The MIT License.

Author

Wojciech Maj
kontakt@wojtekmaj.pl
http://wojtekmaj.pl

Current Tags

  • 1.4.2                                ...           latest (4 years ago)

3 Versions

  • 1.4.2                                ...           4 years ago
  • 1.4.0                                ...           5 years ago
  • 1.3.0                                ...           6 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (7)
Dependents (0)
None

Copyright 2013 - present © cnpmjs.org