classnames
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|
Classnames is a simple JavaScript utility that makes it easier to conditionally join classNames together. This is highly useful in cases where there are dynamic and conditional className properties to be managed. Rather than manually concatenating strings under various conditions, you can use Classnames to handle this process smoothly. It receives any number of arguments which can be a string or object, and it will ignore falsy values.
Classnames is effortlessly easy to install and use. You can install it via npm, Bower, or Yarn using the commands npm install classnames
, bower install classnames
, or yarn add classnames
. In a Node.js, Browserify, or webpack environment, you can include it in the project with the require statement: var classNames = require('classnames');
. Then you can call the classNames
function with the classes you want to join as arguments: `classNames('foo', 'bar');. The output will be 'foo bar', a single string joined with a space delimiter. Code examples are provided in the readme content, including examples of how to use it with React.js, ES2015 dynamic class names, and even versions like 'dedupe' and 'bind' specifically designed for cases where classes need deduplication or for use with CSS modules.
The comprehensive documentation for the Classnames utility is available on its GitHub page. You'll find a detailed explanation of what the package does, how to install and use it, as well as several examples that cover most use cases. Alongside the readme, the package follows the SemVer standard for versioning and the changelog provides a history of changes in the package. Following the examples provided in the documentation, you will be able to cover most, if not all, of the use cases that call for conditional joining of classNames.