Define all visual variants of a button component, size, color, and style, in one structured place instead of scattered conditional logic.
Build a design system where each component's class name combinations are validated at compile time so typos and mismatches are caught early.
Replace ad-hoc class name string concatenation in React or Vue components with a readable, type-safe variant API.
| joe-bell/cva | nodejs/nodejs.org | ritwickdey/vscode-live-server | |
|---|---|---|---|
| Stars | 6,828 | 6,830 | 6,819 |
| Language | TypeScript | TypeScript | TypeScript |
| Setup difficulty | easy | moderate | easy |
| Complexity | 2/5 | 3/5 | 1/5 |
| Audience | developer | developer | developer |
Figures from each repo's GitHub metadata at analysis time.
CVA, short for Class Variance Authority, is a small TypeScript library for managing CSS class names in user interface components. When building UI components that can appear in different styles depending on context, such as a button that might be large or small, filled or outlined, or in a primary or danger color, you end up writing logic to combine the right class names based on those choices. CVA gives you a structured way to define those variations so the logic stays consistent and readable. The library is distributed as an npm package under the name class-variance-authority. It includes TypeScript type definitions, which means the types of your component variants are checked at compile time rather than discovered only when something breaks at runtime. The package is designed to stay small: the bundled and compressed size is minimal, making it practical to include in frontend projects where download size matters. The README for this repository is sparse and points readers to the documentation site at cva.style for actual usage instructions and examples. The project is licensed under Apache 2.0.
Small TypeScript library for managing CSS class name variations in UI components. Define all the style options for a button or card, like size, color, or outline, in one place with full TypeScript type safety.
Mainly TypeScript. The stack also includes TypeScript, npm.
Use freely for any purpose including commercial, as long as you include the license notice. Apache 2.0.
Setup difficulty is rated easy, with roughly 5min to a first successful run.
Mainly developer.
This repo across BitVibe Labs
Verify against the repo before relying on details.