Get started
Install CVA and build your first variant component in minutes.
API Reference
Explore the full API — cva, cx, compose, and defineConfig.
Core Concepts
Learn variants, compound variants, default variants, and composition.
Examples
See CVA in action with React, Vue, Svelte, Astro, and more.
What is CVA?
Class Variance Authority (cva) is a tiny (~1.6KB) TypeScript utility for creating type-safe component variants. Instead of juggling conditional class strings by hand, you declare your variants declaratively and let CVA handle the logic.
Why CVA?
Type-safe variants
Full TypeScript inference — autocomplete for every variant value, and compile-time errors for invalid combinations.
Framework-agnostic
Works anywhere CSS class names work — React, Vue, Svelte, Astro, plain HTML, and more.
Tiny footprint
Under 1.6KB minzipped. No runtime overhead — just string concatenation done right.
Composable
Combine multiple CVA components together with
compose and cx.Key features
- Variants — define visual or behavioral variants (size, intent, state) as named keys with class values
- Compound variants — apply classes only when multiple variant conditions are met simultaneously
- Default variants — set sensible fallback values so callers don’t have to pass every prop
cxutility — a re-exportedclsxalias for merging arbitrary class namescompose— merge the variant props of multiple CVA components into one functiondefineConfig— create a custom instance with anonCompletehook (e.g. to runtailwind-mergeon every output)
Quick install
From v1 onwards the package is also published as
cva. During the beta period use class-variance-authority or alias it — see the installation guide for details.