Javascript
utils
Cn Tailwind Function

Merge static classes with dynamic classes like props from parents

Installation list in one command: npm i clsx tailwind-merge

import { clsx, type ClassValue } from "clsx"
import { twMerge } from "tailwind-merge"
 
export function cn(...inputs: ClassValue[]) { // Type included
    return twMerge(clsx(inputs))
}

Usage

<div className={cn("flex items-center w-full", className)}>
    cn Function for tailwind
</div>
Last updated on