Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report
Generated on Apr 30, 2024 via pnpm

clsx 1.0.4

A tiny (223B) utility for constructing className strings conditionally.
Package summary
Share
0
issues
1
license
1
MIT
Package created
24 Dec 2018
Version published
6 Apr 2019
Maintainers
1
Total deps
1
Direct deps
0
License
MIT

Issues

0
This package has no issues

Licenses

MIT License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
sublicense
private-use
Cannot
hold-liable
Must
include-copyright
include-license
1 Packages, Including:
clsx@1.0.4
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

0
All Dependencies CSV
β“˜ This is a list of clsx 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities

Visualizations

Frequently Asked Questions

What does clsx do?

clsx is a lightweight JavaScript utility that generates className strings conditionally. At a minute 234B in size, it serves as a faster and tinier drop-in alternative for the commonly used classnames module. clsx can accept any mix of Objects, Arrays, Booleans, or Strings as its input, and discards any falsy values. This makes it an excellent tool for assigning class names to HTML elements conditionally in your web projects.

How do you use clsx?

To add clsx to your project, first install it through npm with the command npm install --save clsx. You can then import the clsx function into your JavaScript file with the line import clsx from 'clsx';.

Here is an example of how to use clsx:

import clsx from 'clsx';

// To generate class strings...
let className = clsx('foo', true && 'bar', 'baz');

// To conditionally include classes...
let isActive = true;
let className = clsx('button', isActive && 'button-active');

// To use with Objects, Arrays, mixed types....
let className = clsx('foo', [1 && 'bar', { baz: false, bat: null }, ['hello', ['world']]], 'cya');

In these examples, clsx generates a class string based on the conditions given in its arguments. If a condition is true, clsx includes the related string in the class name.

Where are the clsx docs?

Comprehensive documentation for the clsx package can be found on its GitHub page. This includes detailed usage examples, an API reference, and benchmarks comparing clsx's performance to other className utilities. Furthermore, the page details support for various Node.js versions and browsers, and provides steps to enable class autocompletion using clsx with the popular Tailwind CSS framework. For an even deeper dive, the source code can be examined by following the provided git link: git+https://github.com/lukeed/clsx.git.