Class Variance Authority

A small JavaScript library that turns a component's variants, such as intent and size, into the right list of CSS classes.

In more detail

You call cva() with base classes, a variants object, optional compoundVariants and defaultVariants. The returned function takes props such as { intent: "danger", size: "lg" } and returns a class string. Its VariantProps type lets TypeScript derive the component's props from the same definition.

Related terms

Taught in

References