classix is a highly optimized utility for conditionally joining CSS class names, focusing on speed and minimal bundle size. It distinguishes itself by exclusively accepting string expressions as arguments, diverging from common patterns in libraries like `clsx` and `classnames` which often support object syntax. This design choice simplifies the API, improves typing experience, and enables better performance and a smaller footprint. The current stable version is 2.2.12. The project maintains a frequent release cadence, primarily issuing patch updates for dependency upgrades and minor improvements, as seen in the recent changelog. It supports both ES Modules and CommonJS environments across all major browsers and Node.js versions, provides full TypeScript typing, and has zero runtime dependencies.
npm install classixVerified import paths — ran on the pinned version, not inferred.
Demonstrates basic class joining, conditional class application, and ternary operator usage for 'if/else' logic with `classix`.
Convert object syntax `{'class-name': condition}` to conditional string expressions like `condition && 'class-name'` or `condition ? 'class-name-if-true' : 'class-name-if-false'`.Ensure all arguments passed to `cx` resolve to a string, boolean, null, or undefined. Use conditional string logic instead of object or array patterns found in other libraries.
Rewrite object-based conditional classes using string expressions. For example, change `cx({ 'class-name': condition })` to `cx(condition && 'class-name')`.Refactor object-based class definitions to use conditional string expressions. Instead of `cx({'my-class': someCondition})`, use `cx(someCondition && 'my-class')`.No dependency data recorded yet.