clsx
npmv2.1.1TypeScriptA tiny (239B) utility for constructing className strings conditionally.
Adopt with care
clsx is usable, with caveats. Last published 870 days ago.
- ?Adoption: grade ?, Not reported by this registry.
No download data reported for this package yet.
- DMaintenance: grade D, Poor — a real concern.
Last published 870 days ago.
- AWeight: grade A, Excellent.
Zero runtime dependencies, about 8.4 KB installed.
- BSupply chain: grade B, Good.
This package has a single maintainer (bus factor of 1).
- ALicense: grade A, Excellent.
MIT — permissive, with no copyleft found in the dependency tree.
Grades are computed deterministically from registry metadata collected by PackageGraph — downloads, dependents, publish dates, the resolved dependency tree, maintainer count, and declared licenses. No third-party scores are used.
Install cost
What you actually take on by adding clsx to a project.
Runtime packages this one declares itself.
Distinct packages in the full runtime tree, deduplicated the way a package manager would.
Unpacked size of this package plus its entire runtime tree.
Longest resolved dependency chain below this package.
Compatibility
- Node.js
- node >=6
- Module format
- ESM + CommonJS
- TypeScript
- Types included
- Install scripts
- None
Quick start
A usage example from the clsx README.
import clsx from 'clsx';
// or
import { clsx } from 'clsx';
// Strings (variadic)
clsx('foo', true && 'bar', 'baz');
//=> 'foo bar baz'
// Objects
clsx({ foo:true, bar:false, baz:isTrue() });
//=> 'foo baz'
// Objects (variadic)
clsx({ foo:true }, { bar:false }, null, { '--foobar':'hello' });Dependencies
Declared by clsx v2.1.1. Runtime dependencies are installed with the package; dev dependencies are not.
Dev (3)
Used by
Popular packages that depend on clsx.
Relationship graph
Dependencies (left) and dependents (right) of clsx.
Frequently installed together
TypeScript definitions for node
An extremely fast JavaScript and CSS bundler and minifier.
ECMAScript parser
TypeScript definitions for estree
Next generation testing framework powered by Vite
Programmatic access to information about the AXObject Model
Acorn plugin that parses TypeScript
Parse in reverse
Determine whether an AST node is a reference
Uses export conditions to return environment information in a way that works with major bundlers and runtimes.
Programmatic access to the ARIA specification
Gets the job done when JSON.stringify can't
Release history
No releases in the last two years, typically about 47 days apart.
| Version | Published | Size | License |
|---|---|---|---|
| 2.1.1latest | 2 years ago | 8.4 KB | MIT |
| 2.1.0 | 2 years ago | 8.3 KB | MIT |
| 2.0.1 | 2 years ago | 6.8 KB | MIT |
| 2.0.0 | 3 years ago | 6.6 KB | MIT |
| 2.0.0-next.0 | 3 years ago | 6.6 KB | MIT |
| 1.2.1 | 4 years ago | 5.5 KB | MIT |
| 1.2.0 | 4 years ago | 6.1 KB | MIT |
| 1.1.1 | 6 years ago | 6.1 KB | MIT |
| 1.1.0 | 6 years ago | 6.0 KB | MIT |
| 1.0.4 | 7 years ago | 5.6 KB | MIT |
| 1.0.3 | 7 years ago | 5.2 KB | MIT |
| 1.0.2 | 7 years ago | 5.2 KB | MIT |
| 1.0.1 | 7 years ago | 5.2 KB | MIT |
| 1.0.0 | 7 years ago | 5.0 KB | MIT |
| 0.0.1 | 7 years ago | 4.9 KB | MIT |
Overview
clsx is an npm package that a tiny (239B) utility for constructing className strings conditionally. It has 2 known dependents in the graph. The latest version is 2.1.1, released under the MIT license.
Who should use it
Teams working in the npm ecosystem who need a tiny (239B) utility for constructing className strings conditionally and value a focused solution.
When not to use it
Consider an alternative if you need to or if a more actively-maintained option better fits your npm stack.
Pros
- Ships TypeScript type definitions.
- Clear open-source license (MIT).
- Lean dependency tree (3 direct dependencies).
Cons
- No significant drawbacks detected from available metadata.
Auto-generated from collected registry metadata. No external claims are inferred.
Maintainers
Keywords
Frequently asked questions
Should I use clsx?
clsx is usable, with caveats. Last published 870 days ago.
How do I install clsx?
Run `npm install clsx` to add clsx to your npm project.
What license is clsx released under?
clsx is distributed under the MIT license.
How popular is clsx?
npm does not publish download counts. Within PackageGraph's crawl, 2 known packages depend on clsx.
Is clsx still maintained?
The most recent release of clsx (v2.1.1) was published 2 years ago.
Does clsx run install scripts?
No. clsx does not define preinstall, install, or postinstall scripts, so installing it does not execute publisher-supplied code.