shadcn-syntax-variant-cva
Installation
SKILL.md
shadcn ui : Variant API with cva
shadcn components express their visual variants through class-variance-authority (cva). The single most common source of styling bugs in a shadcn project is misuse of cva or its companion helper cn(). ALWAYS internalise this skill before adding, editing, or reviewing a variants object.
Quick Reference
cva in three lines
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "@/lib/utils"
const buttonVariants = cva("inline-flex items-center", {
variants: { variant: { default: "bg-primary", outline: "border" } },
defaultVariants: { variant: "default" },
})
Three rules apply to every cva call :