Skip to content

Commit 8bef16b

Browse files
authored
Merge pull request #4 from internshipsamyrai44/fix-tailwin-merge-classes
fix: correct tailwind class merge
2 parents 93625a0 + 3ef2065 commit 8bef16b

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

src/lib/utils.ts

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
import { type ClassValue, clsx } from 'clsx'
2-
import { twMerge } from 'tailwind-merge'
2+
import { extendTailwindMerge } from 'tailwind-merge'
3+
4+
import config from '../../tailwind.config'
5+
6+
const twMerge = extendTailwindMerge({
7+
override: {
8+
classGroups: {
9+
'font-size': [...Object.keys(config.theme.fontSize).map(key => key)],
10+
'text-color': [...Object.keys(config.theme.colors).map(key => key)],
11+
},
12+
},
13+
})
314

415
export function cn(...inputs: ClassValue[]) {
516
return twMerge(clsx(inputs))

tailwind.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/** @type {import('tailwindcss').Config} */
22

3-
const plugin = require('tailwindcss/plugin')
3+
import plugin from 'tailwindcss/plugin'
44

55
export default {
66
content: ['./index.html', './src/**/*.{js,ts,jsx,tsx}'],

tsconfig.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@
3535
"declarationMap": true,
3636

3737
// Importing .js files is not allowed, enable if needed.
38-
"allowJs": false,
38+
"allowJs": true,
39+
"checkJs": false,
3940

4041
// Fix the mis-match of behaviors between ES import and CommonJS require.
4142
"esModuleInterop": true,
@@ -69,6 +70,6 @@
6970
"noUnusedLocals": false,
7071
"noUnusedParameters": true
7172
},
72-
"include": ["src"],
73+
"include": ["src", "tailwind.config"],
7374
"exclude": ["./src/**/*.stories.*"]
7475
}

0 commit comments

Comments
 (0)