Get StartedAdd Utilities
Add Utilities
This code is widely used in Luxe, it is responsible for merging classes when they have conditionals and for organizing the code.
1
Install dependencies
Terminal
npm i clsx tailwind-merge
2
Create a file with the path utils/cn.ts
utils/cn.ts
import { type ClassValue, clsx } from "clsx";
import { twMerge } from "tailwind-merge";
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}