Created
January 2, 2025 16:48
-
-
Save codemile/340412f5cd47fdbf05b5110d82fd6bb9 to your computer and use it in GitHub Desktop.
Utility function to merge Tailwind classes with clsx and twMerge, plus a TypeScript type for props with className.
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
import {type ClassValue, clsx} from 'clsx'; | |
import {twMerge} from 'tailwind-merge'; | |
export type PropsWithClassName<P = unknown> = P & { | |
className?: ClassValue | undefined; | |
}; | |
export function cn(...inputs: ClassValue[]) { | |
return twMerge(clsx(inputs)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment