Last active
January 27, 2025 09:21
-
-
Save sanusart/a7865e6ab0ed53ca0e9715763e2071d1 to your computer and use it in GitHub Desktop.
Custom cn() function #util #javascript #typescript #js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function cn(...classes: (string | undefined | null | false)[]) { | |
return classes.filter(Boolean).join(' '); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This function meant to replace tailwind provided util:
By using this function we can get rid of 2 dependencies - clsx and tailwind-merge, but we loose the abilities of tailwind-merge like silently merging duplicate classes (IMHO I prefere to do it myself for less magic and more visibility, but that's just me).