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.
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.
← joe-bell on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.