About Cn function / cn()
Answered
West African Lion posted this in #help-forum
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));
}
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
@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:
tsx
import { type ClassValue, clsx } from "clsx";
import { twMerge } from "tailwind-merge";
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}
West African LionOP
So, I still have to manually write the function, right?
thought it was a built in function
@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