Skip to content

Commit 0b23b5f

Browse files
feat: custom twMerge utility (#16)
1 parent 5aad6de commit 0b23b5f

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

.changeset/tasty-walls-float.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@zenml-io/react-component-library": patch
3+
---
4+
5+
provide custom `twMerge` utility

src/utilities.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,28 @@
11
import { clsx, type ClassValue } from "clsx";
2-
import { twMerge } from "tailwind-merge";
2+
import { extendTailwindMerge } from "tailwind-merge";
3+
4+
const customTwMerge = extendTailwindMerge({
5+
classGroups: {
6+
fontSize: [
7+
"text-text-xs",
8+
"text-text-sm",
9+
"text-text-md",
10+
"text-text-lg",
11+
"text-text-xl",
12+
"text-display-xs",
13+
"text-display-sm",
14+
"text-display-md",
15+
"text-display-lg",
16+
"text-display-xl"
17+
]
18+
}
19+
});
320

421
/**
522
* Merges tailwind utilities, and allows the usage of the clsx syntax in addition
623
* @param inputs list of class names
724
* @returns
825
*/
926
export function cn(...inputs: ClassValue[]) {
10-
return twMerge(clsx(inputs));
27+
return customTwMerge(clsx(inputs));
1128
}

0 commit comments

Comments
 (0)