Class Variance Authority
Type-safe CSS class composition for component variants and styling.
3. Used by agents' projects
Dependency in 1,020 public GitHub projects set up for AI coding agents that we scanned (16.3%).
4. Agent access
Agent skills for this library in the skills catalog; community skills are written by others, read them before you install.
cva.style/llms.txtFrom the package registry and GitHub, checked daily. Tap a verdict to see its source.How we checkedReport an error
What Class Variance Authority does
cva brings the variants API that the site credits Stitches with pioneering to plain class strings, so projects on Tailwind CSS or hand-written CSS get typed variant props without a CSS-in-TS library.
Class Variance Authority popularity
Gid Score measures public popularity and activity, not quality. How the Gid Score is calculated
How Class Variance Authority is used
- Class Variance Authority is a dependency in 1,020 of the 6,258 public GitHub projects set up for AI coding agents that we scanned (21.0% of the 4,867 JavaScript/TypeScript ones), #2 of 230 in ui components and icons.
- Counting the projects our scan samples by dependency (Solana 3,067, Ethereum and EVM 1,774, 3D and games 3,130, agent frameworks and SDKs 13,750), it appears in 3,835; those are left out of every share on this page.
- Projects that use it most often also use Tailwind Merge (98.3%), clsx (97.9%), Lucide React (92.2%).
- It is more common in projects set up for Roo Code (27.9%) than for OpenAI Codex (13.9%).
By coding agent
Often used with
Class Variance Authority in practice
Strengths
The site says CSS-in-TS libraries such as Stitches and Vanilla Extract handle type-safe variants. It pitches cva at people who need control over stylesheet output, use Tailwind CSS, or prefer writing their own CSS.
In one developer's design system, the Button's prop type is built with <code>VariantProps<typeof buttonVariants></code>, where <code>buttonVariants</code> is the cva definition with <code>variant</code> and <code>size</code> options.
The site lists a size of 596 B, minified and compressed with Brotli. It sits in the stats area next to the per-package download figures, so it most likely refers to one package rather than both.
The maintainers write that an earlier custom <code>cx</code> utility could not handle variadic arguments or objects. They switched to clsx, which added those features with "quite literally zero increase to the bundle size."
Watch out for
The releases page lists v0.7.1, published 2024-11-26, as the latest release. The site banner says cva@1.0 is in beta.
The stable package is <code>class-variance-authority</code> and the beta is <code>cva</code>. They have separate docs, and the abridged LLM bundle covers the stable docs only.
The site calls cva "a privately-maintained free open-source project" and asks for sponsorship to fund development.
More about Class Variance Authority
Funding
- GitHub Sponsors: https://github.com/joe-bell
- Polar: https://polar.sh/cva
Packages around it
- tailwind-merge: Tailwind class conflict merging
- clsx: Conditional className strings
- lucide-react: Icon components
- @radix-ui: Unstyled UI primitives
- tailwindcss: Utility-first CSS
- next-themes: Theme switching
More in UI components and icons
Alternatives
Class Variance Authority This page
Get started
Install it.
npm install class-variance-authorityRules for your agent
## Class Variance Authority
- The docs cover two packages: `class-variance-authority` (stable) and `cva` (the 1.0 beta, documented at https://cva.style/beta). Check which one the project already depends on before writing imports.
- The site says cva works "with Tailwind CSS or any other styling approach", so it can be used with plain CSS class names as well as Tailwind utilities.
- For stable docs only, fetch `https://cva.style/llms-small.txt`. For stable plus beta, fetch `https://cva.style/llms-full.txt`. The beta alone has `https://cva.style/_llms-txt/cvabeta.txt`.
- To read a single page as Markdown, add `.md` to its path without a trailing slash (home pages: `/index.md`, `/beta/index.md`), or send `Accept: text/markdown`.
- Suggested pattern, taken from a community example rather than the official docs: type component props with `VariantProps<typeof buttonVariants>` and pass the cva result plus `className` through a merge helper (`cn(buttonVariants({ variant, size }), className)`).