FAQs
Why don't you provide a `styled` API?
Why don't you provide a `styled` API?
Long story short: it’s unnecessary.
cva encourages you to think of components as traditional CSS classes:- Less JavaScript is better
- They’re framework agnostic; truly reusable
- Polymorphism is free — just apply the class to your preferred HTML element
- Less opinionated; you’re free to build components with
cvahowever you’d like
How can I create responsive variants like Stitches.js?
How can I create responsive variants like Stitches.js?
You can’t.Create a bespoke variant that encodes the breakpoint
cva doesn’t know about how you choose to apply CSS classes, and it doesn’t want to.Two approaches work well in practice:Show and hide elements at different breakpointsResponsive variants are typically rare in practice. Showing and hiding different elements is usually sufficient. Building a generalised responsive-variants system requires deep integration with each build tool and CSS framework — that work is not planned at this time.
What's the difference between `class-variance-authority` and `cva`?
What's the difference between `class-variance-authority` and `cva`?
Can I use CVA without Tailwind CSS?
Can I use CVA without Tailwind CSS?
Yes. CVA is CSS-framework agnostic.It works with plain CSS class names, CSS Modules, any utility library, or no CSS framework at all.
cva simply concatenates strings — it has no knowledge of or dependency on Tailwind CSS.components/button.ts
button.css
How do I handle Tailwind class conflicts?
How do I handle Tailwind class conflicts?
Tailwind resolves styles by the order classes appear in your stylesheet, not your Then import
class attribute. Two conflicting utilities — for example p-2 and p-4 — will not resolve predictably when merged at runtime.Use tailwind-merge via defineConfig to resolve conflicts globally across all components:lib/utils.ts
cva, cx, and compose from your local module instead of from cva directly. Every component that uses the re-exported functions will have conflict resolution applied automatically.See the Tailwind CSS guide for the full setup.Does CVA work with CSS Modules?
Does CVA work with CSS Modules?
Yes. Pass CSS Module class names the same way you would any other string.Because CSS Modules generate unique class names at build time, there are no runtime conflicts to worry about.
components/button.ts
button.module.css
