Skip to content

Create custom merge function to support custom utility classes (extended theme) #48

Closed Answered by dcastil
charkour asked this question in Help
Discussion options

You must be logged in to vote

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 need createTailwindMerge in all cases, but in this one yes.

Here is how to create it in v0.7.1:

import { createTailwindMerge } from 'tailwind-merge'

export const twMerge = createTailwindMerge((getConfig) => {
    const config = getConfig()

    config.classGroups.shadow.push({ shadow: ['light', 'dark'] })

    return config
})

In v0.8.0 which will be released soon you can do it a little cleaner (use #48 (reply in thread) instead):

import { createTailwindMerge, getDefaultConfig, mergeConfigs } from 'tailwind-merge'

export const twMerge = createTailwind…

Replies: 7 comments 11 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
9 replies
@dcastil
Comment options

@dcastil
Comment options

@charkour
Comment options

@charkour
Comment options

@dcastil
Comment options

Answer selected by dcastil
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@dcastil
Comment options

@nenostra
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
context-v0 Related to tailwind-merge v0
3 participants
Converted from issue

This discussion was converted from issue #46 on October 21, 2021 15:24.