cn
A utility function to merge Tailwind class names using clsx and tailwind-merge. Use this library to write conditional classes in your components.
Import
import { cn } from "@aeonkit/helpers";Parameters
cn accepts a single parameter, which can be a string, an object, or a conditional statement.
Usage
Simple
cn('text-center bg-slate-100 transition duration-300 ease-in-out')Conditional logic
cn('text-center bg-slate-100', error && 'text-red-500 bg-blue-500')With an object
cn('text-center bg-slate-100', { 'text-red-500': error, 'bg-blue-500': !error })Returns
A string of merged class names.