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 possible to only import a subset of default config for tailwind-merge #228

Open
dcastil opened this issue May 19, 2023 · 1 comment
Labels
context-v1 Related to tailwind-merge v1 feature request

Comments

@dcastil
Copy link
Owner

dcastil commented May 19, 2023

Hi @dcastil, another approach that wouldn't require help from the tailwind team would be to break up the default config into core plugins. Right now the default config is all or nothing, you either get all the classGroups from the default with extendTailwindMerge or start from scratch with createTailwindMerge. Since tailwind-merge already supports merging configs, would it be feasible to export configs representing all the tailwind core plugins separately? Then users could specify a subset of commonly overridden plugins to reduce their bundle size.

It's common to override things like height, width, color, and some of the flex and grid properties. I would think it's less common to want to override properties like backdrop. The only issue would be if consumers get confused on which classes twMerge supports, though if they're using any tailwind plugins that's potentially already an issue.

Originally posted by @Rinaldo in #185 (reply in thread)

@dcastil
Copy link
Owner Author

dcastil commented May 19, 2023

I think the best path forward with this is to keep the library exports twMerge and getDefaultConfig untouched (you get the full config there as expected, no breaking change) and add additional exports for people who choose to limit merging for reduced bundle size.

I could imagine an API like this:

import {
    createTailwindMerge,
    withConfigs,
    getDefaultLayoutConfig,
    getDefaultFlexboxAndGridConfig,
    getDefaultSpacingConfig,
    getDefaultSizingConfig,
} from 'tailwind-merge'

export const twMerge = createTailwindMerge(
    withConfigs(
        getDefaultLayoutConfig,
        getDefaultFlexboxAndGridConfig,
        getDefaultSpacingConfig,
        getDefaultSizingConfig,
    )
)

@dcastil dcastil added the context-v1 Related to tailwind-merge v1 label Oct 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
context-v1 Related to tailwind-merge v1 feature request
Projects
None yet
Development

No branches or pull requests

1 participant