Next.js Discord

Discord Forum

About Cn function / cn()

Answered
West African Lion posted this in #help-forum
Open in Discord
West African LionOP
Quick question. Where should I import cn function from?
Answered by B33fb0n3
normally it should be automatically installed after you installed tailwind or shadcn and placed inside your utils.ts in your /lib folder. If you dont have it:
import { type ClassValue, clsx } from "clsx";
import { twMerge } from "tailwind-merge";

export function cn(...inputs: ClassValue[]) {
    return twMerge(clsx(inputs));
}
View full answer

6 Replies

@West African Lion Quick question. Where should I import cn function from?
normally it should be automatically installed after you installed tailwind or shadcn and placed inside your utils.ts in your /lib folder. If you dont have it:
import { type ClassValue, clsx } from "clsx";
import { twMerge } from "tailwind-merge";

export function cn(...inputs: ClassValue[]) {
    return twMerge(clsx(inputs));
}
Answer
@West African Lion So, I still have to manually write the function, right?
when you install tailwind css or shadcn the function should be automatically installed. But yea, it's still written down inside your utils.ts
happy to help