tailwind-class-merge
Version:
A utility function that combines `clsx` and `tailwind-merge` to ensure that a string of Tailwind CSS classnames are free of duplications and conflicts.
17 lines (16 loc) • 850 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.classMerge = void 0;
const clsx_1 = require("clsx");
const tailwind_merge_1 = require("tailwind-merge");
/**
* Combines classnames using `clsx` and then merges the result with `twMerge` to optimize Tailwind CSS class utilities.
* This function ensures that the resulting class string is free of duplicate or conflicting Tailwind utility classes.
*
* @param {ClassValue[]} inputs - An array of class values that can be strings, objects, or arrays that will be processed by `clsx`.
* @returns {string} A string that represents the merged and optimized class names for use in a className attribute in React components.
*/
const classMerge = (...inputs) => {
return (0, tailwind_merge_1.twMerge)((0, clsx_1.clsx)(inputs));
};
exports.classMerge = classMerge;