-
Hello, thanks for this awesome package. I noticed an issue with the // Actual
twMerge('shadow-md shadow-lg shadow-light shadow-dark') // 'shadow-lg shadow-light shadow-dark'
// Expected
twMerge('shadow-md shadow-lg shadow-light shadow-dark') // 'shadow-dark' This works properly with the normal box shadow classes. Perhaps I to make a custom tailwind merge function with the light and dark suffixes? Thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments 11 replies
-
Inside the module.exports = {
mode: 'jit',
theme: {
extend: {
boxShadow: {
'dark': '0 3px 8px #ccc',
'light': '0px 2px 5px 0px HSLA(0, 0%, 84.3%, 0.5);',
},
},
},
}; |
Beta Was this translation helpful? Give feedback.
-
Looking through the source code, it looks like I need to create a custom tailwind merge function. How would that be done to only add the box shadow custom classes? |
Beta Was this translation helpful? Give feedback.
-
Hi @charkour! Indeed, if you're using a custom Tailwind config, you need to use Here is how to create it in import { createTailwindMerge } from 'tailwind-merge'
export const twMerge = createTailwindMerge((getConfig) => {
const config = getConfig()
config.classGroups.shadow.push({ shadow: ['light', 'dark'] })
return config
})
import { createTailwindMerge, getDefaultConfig, mergeConfigs } from 'tailwind-merge'
export const twMerge = createTailwindMerge(() =>
mergeConfigs(getDefaultConfig(), {
classGroups: {
shadow: [{ shadow: ['light', 'dark'] }],
},
})
) If you're wondering where that class group name Let me know if that helps. |
Beta Was this translation helpful? Give feedback.
-
This is perfect, I had something similar to your Thanks for the quick response! |
Beta Was this translation helpful? Give feedback.
-
Yeah 😄 I also think that this is still way too cumbersome and created #47. That will be in |
Beta Was this translation helpful? Give feedback.
-
Moving this to discussions as this isn't a bug in tailwind-merge. |
Beta Was this translation helpful? Give feedback.
-
Hello @dcastil , if I have custom |
Beta Was this translation helpful? Give feedback.
Hi @charkour! Indeed, if you're using a custom Tailwind config, you need to use
createTailwindMerge
and create a config for it. You don't needcreateTailwindMerge
in all cases, but in this one yes.Here is how to create it in
v0.7.1
:In(use #48 (reply in thread) instead):v0.8.0
which will be released soon you can do it a little cleaner