Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make it easier to override elements in tailwind-merge config #199

Closed
dcastil opened this issue Feb 8, 2023 · 2 comments · Fixed by #294
Closed

Make it easier to override elements in tailwind-merge config #199

dcastil opened this issue Feb 8, 2023 · 2 comments · Fixed by #294
Labels
breaking Is breaking change context-v2 Related to tailwind-merge v2 feature Is new feature
Milestone

Comments

@dcastil
Copy link
Owner

dcastil commented Feb 8, 2023

If someone wants to add classes to the tailwind-merge config, that's no problem.

const twMerge = extendTailwindMerge({
    classGroups: {
        // additions to the config go here
    }
})

But if someone wants to override the config in some places, that gets nasty really fast

const twMerge = createTailwindMerge(() => {
    // Need to import this function and create default config myself
    const config = getDefaultConfig()
    
    // Do I mutate the config?
    config.classGroups.somethingThatExists = []
    
    // Do I mutate arrays? What if arrays are reused?
    config.classGroups.somethingElseThatExists.push({})
    
    // Feels weirdly imperative
    return config
})

It would be really nice if I could override parts of the config declaratively and safely with extendTailwindMerge. I think I could use the same pattern as Tailwind CSS and rely on a extend key in each object to add config to existing one and keep the current config to override elements like this:

const twMerge = extendTailwindMerge({
    classGroups: {
        // overrides to the config go here
        extend: {
            // additions to the config go here
        }
    }
})

This would be a breaking change and therefore only makes sense in a new major version.

@dcastil dcastil added breaking Is breaking change feature request labels Feb 8, 2023
@dcastil dcastil added this to the v2 milestone Feb 8, 2023
@dcastil
Copy link
Owner Author

dcastil commented Feb 8, 2023

Another idea is to use a different name. extendTailwindMerge doesn't sound very fitting if you can also override. This would also make it possible to ship this as a non-breaking change or make the breaking change more obvious.

@github-actions
Copy link

This was addressed in release v2.0.0.

@dcastil dcastil added the context-v2 Related to tailwind-merge v2 label Oct 30, 2023
@dcastil dcastil added feature Is new feature and removed feature request labels Oct 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking Is breaking change context-v2 Related to tailwind-merge v2 feature Is new feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant