Utility function for merging Tailwind CSS class names efficiently.
To install this package, run:
# deno
deno add jsr:@vyn/cn
# or import directly with a jsr specifier
import * as mod from "jsr:@vyn/cn";
# npm
npx jsr add @vyn/cnThe package exports a single function cn which can be used to merge Tailwind CSS class names:
import { cn } from '@vyn/cn';
const className = cn('text-red-500', 'bg-blue-200', 'p-4');
const classNames = cn(['text-red-500', 'bg-blue-200', 'p-4']);Merges the provided class names, resolving conflicts and duplicates efficiently.
inputs: An array of class names or objects representing class names.- Returns: A string of merged class names.
This package depends on:
- clsx: A tiny utility for constructing
classNamestrings conditionally. - tailwind-merge: A utility function to efficiently merge Tailwind CSS classes without style conflicts.