web-styling-cva
CVA (Class Variance Authority) Patterns
Quick Guide: Use CVA to define type-safe component variants with a declarative API. Define base classes, variant groups (size, intent, state), compound variants for combined conditions, and default values. Extract types with
VariantProps. Works with any CSS approach (utility classes, CSS modules, plain CSS). Always setdefaultVariants, always define bothtrue/falsefor boolean variants, always useVariantPropsfor type extraction.
<critical_requirements>
CRITICAL: Before Using This Skill
All code must follow project conventions in CLAUDE.md (kebab-case, named exports, import ordering,
import type, named constants)
(You MUST define all variant options in the variants object - NEVER use conditional class logic outside cva)
(You MUST use VariantProps to extract types - NEVER manually define variant prop types)
(You MUST use defaultVariants for initial state - NEVER rely on undefined props for defaults)
(You MUST use compoundVariants for multi-condition styles - NEVER nest ternaries for combined states)