wealth/packages/island/src/tools/cn/cn.ts

30 lines
657 B
TypeScript

import { clsx, type ClassValue } from 'clsx';
import { extendTailwindMerge } from 'tailwind-merge';
import {
CONTAINERS,
NAMED_SPACING,
SHADOWS,
TEXT_SIZES,
Z_LAYERS,
} from './constants';
const twMerge = extendTailwindMerge({
extend: {
theme: {
text: [...TEXT_SIZES],
shadow: [...SHADOWS],
spacing: [...NAMED_SPACING],
container: [...CONTAINERS],
},
classGroups: {
z: [{ z: [...Z_LAYERS] }],
},
},
});
/** Joins class names and resolves Tailwind conflicts, so a caller's class overrides a component's. */
export function cn(...inputs: ClassValue[]): string {
return twMerge(clsx(inputs));
}