clsx: Conditional Classname Utility
JSON →clsx is a compact (239B gzipped) and highly efficient utility for conditionally constructing `className` strings in JavaScript and TypeScript applications. It offers a faster and smaller alternative to similar libraries like `classnames`. The package is actively maintained, with recent releases like v2.1.1, suggesting a steady cadence of minor features and patches. Key differentiators include its minimal footprint, support for various argument types (strings, objects, arrays, and nested structures), and the `clsx/lite` submodule (140B gzipped) for string-only use cases, particularly beneficial in environments like Tailwind CSS. It ships with TypeScript types and is supported across all Node.js versions and browsers supporting `Array.isArray` (IE9+).
Traffic · last 30 days ↓29% vs prev 7d
top countries 🇺🇸 United States · 🇩🇪 Germany · 🇸🇬 Singapore · 🇨🇦 Canada · 🇫🇷 France