classix
The tiniest and fastest utility for conditionally joining classNames using plain string expressions.
Repository Health
Technical Analysis
classix is a minimal utility for conditionally joining CSS class names into a single string. It exposes a single cx function that concatenates any number of string expressions, skipping falsy values, which makes it a natural fit for conditional styling in React and Tailwind projects.
Unlike clsx or classnames, classix deliberately accepts only string expressions — no objects or arrays of conditions. This constraint yields a simpler, consistent API, a smaller bundle footprint, and faster runtime performance, while conditions are expressed naturally with && and ternary operators.
What You Get
- A single
cxfunction (default and named export) that joins className strings - Automatic removal of falsy values so
condition && 'class'just works - Full TypeScript types for a typed, autocomplete-friendly API
- A very small bundle size and best-in-class runtime performance
- Zero dependencies and ESM/CJS compatibility
Common Use Cases
- Conditionally composing Tailwind utility classes in React components
- Toggling classes based on props or state with ternaries and
&& - Replacing clsx/classnames where only string conditions are needed to shrink bundle size
- Building className strings in any JSX framework or plain JavaScript
Under The Hood
Architecture - The entire library is a single tiny function that iterates its arguments, keeps the truthy string values, and joins them with a space. There is no object/array parsing branch, which is precisely why it is smaller and faster than clsx-style utilities. Tech Stack - Written in TypeScript and published as both ESM and CJS with type declarations; zero runtime dependencies. Tooling includes benchmark and size-comparison scripts and Codecov-tracked coverage. Code Quality - Despite its size, the repo maintains full test coverage, benchmarks against competitors, and typed exports — a well-cared-for micro-library. API Design - The API is intentionally minimal: import cx, pass string expressions, get a string. Conditions read naturally (isActive && 'active', big ? 'p-4' : 'p-2'), so there is essentially nothing to learn for anyone familiar with className joining.