cva or plain props for 60 shared components, 5 devs and nobody who owns design Components
We have about 60 components in a shared package. Currently every variant is a ternary in a template literal and some of them are four levels deep and genuinely unreadable.
The obvious move is cva. The thing stopping me is that five people have to learn it and none of us is a designer, so I suspect the mess is a symptom rather than the disease. Anyone regretted going one way or the other at roughly this size?
@notetaking_ivo · 4w ago · 2 replies
cva earns its keep precisely when variants combine - size times tone times state - and you are tired of a ternary that has to know about all three. That is real and your four-deep template literal is the symptom.
Out of 60 components, maybe 12 will actually have combinatorial variants. Do those. Leave a
Divideras a div with props. Reaching for one API for all 60 is how you end up with a variant config for components that have exactly one appearance.The failure mode at 5 people with no design owner is not the API though. It is that everyone adds a variant and nobody ever deletes one, so in a year
Buttonhas 9 tones, 4 of which appear once. Put variant names in code review explicitly. It is a social fix for a social problem.Reply
Report
@burr_bennet · 4w ago
Add tailwind-merge at the same time or your escape hatch will not work. A consumer passing
className="p-8"on a component whose variant emitsp-4gets whichever one the compiler happened to put last in the stylesheet, which is not the one they wrote, and it will look correct in one place and wrong in another.Reply
Report