CVA
UI library · Free
Class Variance Authority: it defines component variants and maps prop combinations to CSS classes and TypeScript types.
Also known as: joe-bell/cva; class-variance-authority; cva

What you can use for free
Code and local use under Apache-2.0.
Paid features and costs
Computing resources, self-hosting, and external services are paid for separately if used.
Access and limitations
Code and local use under Apache-2.0. Computing resources, self-hosting, and external services are paid for separately if used.
Use cases
- Define typed UI component variants
- Connect prop combinations to class rules and test compound variants
Example workflow
A possible workflow; this is not a report of hands-on testing.
Define typed UI component variants.
Before you start
- The component's design, states, and data.
- A compatible framework and the project's styles.
Steps
- Identify component size, appearance, and state variants.
- Connect prop combinations to class rules and test compound variants.
- Configure styles and check empty, loading, and error states.
Check your result
- The keyboard, focus indicators, and a screen reader let users complete the action.
- The component works on a narrow screen and with long data values.
Choosing CVA
Define typed UI component variants
Choose this when
- Define typed UI component variants
- Connect prop combinations to class rules and test compound variants
Requirements
- The application defines classes and CSS; CVA does not provide a standalone visual component library.
Things to consider
- Costs and limits of free use: Computing resources, self-hosting, and external services are paid for separately if used.
- Terms of use: Apache-2.0 for the code; third-party components retain their own terms.
Frequently asked questions
What can you use for free in CVA?
Code and local use under Apache-2.0.
What additional costs might arise with CVA?
Computing resources, self-hosting, and external services are paid for separately if used.
What terms of use matter for CVA?
Apache-2.0 for the code; third-party components retain their own terms.
How do you get started with CVA?
Identify component size, appearance, and state variants. Connect prop combinations to class rules and test compound variants. Configure styles and check empty, loading, and error states.
What are compoundVariants and defaultVariants for?
CVA assembles classes from variants, including booleans. defaultVariants defines defaults; compoundVariants adds classes for combined conditions. Tailwind is optional. The documentation recommends SSR/SSG for static components to avoid sending unnecessary JavaScript to browsers.
License
Apache-2.0 for the code; third-party components retain their own terms.
Apache 2.0 — permissive license with patent terms
You can use and modify the code in commercial and closed-source projects. When distributing it, retain the license and relevant notices, identify modified files, and include NOTICE if provided. Authors grant a limited patent license for their contributions; it does not grant permission to use trademarks.
License termsTechnologies and topics
- CVA
- UI
- Development