shadcn-syntax-variant-cva

Official

Build type-safe component variants with cva.

AuthorImpertio-Studio
Version1.0.0
Installs0

System Documentation

What problem does it solve?

This Skill prevents shadcn ui styling bugs caused by incorrect use of class-variance-authority (cva) and its required integration patterns, especially when variant classes don’t apply as expected or when caller className overrides fail.

Core Features & Use Cases

  • Correct cva variant construction: Ensures variants, compoundVariants, and defaultVariants are defined using the canonical cva(base, config) structure so the right classes are produced for each prop combination.
  • Reliable className merging with cn(): Enforces the rule that every cva output must be wrapped in cn() (clsx + tailwind-merge) so Tailwind conflicts resolve deterministically and caller overrides reliably win.
  • Type-safe variant props with VariantProps: Guides using VariantProps<typeof yourVariants> to keep the component’s variant API accurate and extensible without duplicating string unions.
  • Radix Slot (asChild) integration: Covers the polymorphic rendering pattern so Button-like components can render a single child element (e.g., Link) while preserving styling and avoiding runtime Slot errors.

Quick Start

Ask the AI to “update my shadcn component’s cva variants and ensure className overrides work correctly using cn() and VariantProps, including any asChild/Slot considerations,” and provide the current variants, component code, Tailwind version (v3 or v4), and the symptom you’re seeing.

Dependency Matrix

Required Modules

None required

Components

references

💻 Claude Code Installation

Recommended: Let Claude install automatically. Simply copy and paste the text below to Claude Code.

Please help me install this Skill:
Name: shadcn-syntax-variant-cva
Download link: https://github.com/Impertio-Studio/shadcn-ui-Claude-Skill-Package/archive/main.zip#shadcn-syntax-variant-cva

Please download this .zip file, extract it, and install it in the .claude/skills/ directory.
View Source Repository

Agent Skills Search Helper

Install a tiny helper to your Agent, search and equip skill from 471,000+ vetted skills library on demand.