CVA variant builder

Write variants as one line each and get the cva() call, the defaults and the VariantProps type, in the shape shadcn components use.

txt
CVAts
The result appears here
Made something you like?See it in real components

Questions

What is the input format?+

One rule per line. base: for the classes every instance carries, then group: option = classes for each variant, and default: group=option for the defaults. Anything else on its own line is treated as more base classes.

Why CVA rather than a switch?+

Because the variants become a type. VariantProps reads the object back out, so the component's props are exactly the options you defined and a typo is a compile error rather than a missing class.

How does this interact with cn()?+

CVA composes the classes, cn() resolves the conflicts when a caller passes their own. The usual shape is cn(buttonVariants({ variant, size }), className), and the merge playground shows what that does.

Related tools

The tools are free. So is most of the library.

1935 blocks and 989 pieces for shadcn/ui and Tailwind, built on the same tokens these tools write. Install one with a command and the code is yours.

No signup for the tools. MIT for free blocks, commercial licence for Pro.

Markdown version