New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

merge-class-names

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

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.

  • 1.4.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

npm downloads CI 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'.
  • Use it in className like so: <div className={mergeClassNames('foo', condition && 'bar', arrayOfClasses)} />

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
https://wojtekmaj.pl

Keywords

FAQs

Package last updated on 26 Aug 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc