defaultVariants
A CVA option giving the variant values to use when the caller does not pass one.
In more detail
With defaultVariants: { intent: "primary", size: "sm" }, calling button() with no arguments still produces a complete, valid set of classes. They also make the component's normal appearance explicit in one place instead of implied by missing props.
Related terms
- 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.
- variant — A named option of a component, such as intent primary or danger and size sm or lg, each mapped to its own styling.
Taught in
- Class Variance Authority: Type-Safe Variant & Prop Orchestration — Design Systems & Component Engineering