best way to create reusable components with tailwind and react

i am exploring different ways to create reusable components using tailwind and react and found this https://github.com/enochndika/kimia-UI/blob/main/src/packages/button/button.tsx. is this the best way to do this?
17 Replies
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
julius
julius3y ago
does it provide intellisense?
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
julius
julius3y ago
nice
nexxel
nexxelOP3y ago
interesting i always thought i hate cva but it seems nice thanks i'll try this i am loving it thanks!
Samyar
Samyar3y ago
you can add component classes it's kinda like the cva lib mentioned above
@layer components {
.select2-dropdown {
@apply rounded-b-lg shadow-md;
}
.select2-search {
@apply border border-gray-300 rounded;
}
.select2-results__group {
@apply text-lg font-bold text-gray-900;
}
/* ... */
}
@layer components {
.select2-dropdown {
@apply rounded-b-lg shadow-md;
}
.select2-search {
@apply border border-gray-300 rounded;
}
.select2-results__group {
@apply text-lg font-bold text-gray-900;
}
/* ... */
}
so u can use .select2-search instead of border border-gray-300 rounded
nexxel
nexxelOP3y ago
aaa i don't wanna use @apply tbh and this is like class based components i prefer the way cva does it where its prop based but thanks for the suggestion!
benten
benten3y ago
cva is good, also twind has it's own standalone version which is typesafe (idk if cva is or not)
benten
benten3y ago
Twind
Twind
The smallest, fastest, most feature complete tailwind-in-js solution in existence
benten
benten3y ago
Although I've been thinking about this model and wondering if there isn't anything better
nexxel
nexxelOP3y ago
yes cva is very typesafe i am loving it
benten
benten3y ago
like you can do className={button({size: "small"})} /> and you get typesafety for each variant?
nexxel
nexxelOP3y ago
yeah
nexxel
nexxelOP3y ago
idk if you mean this
benten
benten3y ago
interesting
Want results from more Discord servers?
Add your server