clsx is a tiny JavaScript utility (roughly a few hundred bytes) for constructing className strings conditionally, commonly used in React and other component frameworks. It is intended as a faster and smaller drop-in replacement for the popular classnames package, but with a minimalistic API and implementation. The function accepts any number of arguments in a variety of forms: strings, numbers, arrays, and objects where truthy values indicate which classes to include. It then returns a deduplicated, space-separated class string that can be applied directly to HTML or JSX className attributes. The library is distributed in multiple formats (ESM, CommonJS, and UMD) so it works well in bundlers, Node environments, and direct tags. Because it has zero dependencies and a stable API, it is widely used in both small projects and large production codebases where bundle size is a concern.

Features

  • Tiny helper for conditionally building className strings from mixed arguments
  • Compatible with strings, numbers, arrays, and object maps of class names to booleans
  • Faster and smaller drop-in replacement for the classnames module in many cases
  • Distributed as ES Module, CommonJS, and UMD bundles for broad compatibility
  • Zero dependencies and a very small footprint in JavaScript bundles
  • Simple, predictable behavior that works seamlessly in React and other view libraries

Project Samples

Project Activity

See All Activity >

Categories

Build Tools

License

MIT License

Follow clsx

clsx Web Site

Other Useful Business Software
Build Securely on AWS with Proven Frameworks Icon
Build Securely on AWS with Proven Frameworks

Lay a foundation for success with Tested Reference Architectures developed by Fortinet’s experts. Learn more in this white paper.

Moving to the cloud brings new challenges. How can you manage a larger attack surface while ensuring great network performance? Turn to Fortinet’s Tested Reference Architectures, blueprints for designing and securing cloud environments built by cybersecurity experts. Learn more and explore use cases in this white paper.
Download Now
Rate This Project
Login To Rate This Project

User Reviews

Be the first to post a review of clsx!

Additional Project Details

Programming Language

JavaScript

Related Categories

JavaScript Build Tools

Registered

2025-11-20