Skip to content

Custom spacing without "full" does not merge while "auto" does #377

Open
@WesselKroos

Description

@WesselKroos

Describe the bug

Our tailwind config has a custom spacing without the Tailwind default "full" and "auto" spacings. But the "auto" spacing is correctly merged while the "full" spacing is not.

twMerge(...) Results:

w-full w-auto = w-full w-auto
w-8 w-16 = w-16
w-8 + w-16 = w-16
w-full + w-16 = w-full w-16
w-8 + w-full = w-8 w-full
w-8 + w-auto = w-auto
w-auto + w-16 = w-16
w-auto + w-full = w-auto w-full
w-full + w-auto = w-full w-auto
h-8 + h-16 = h-16
h-full + h-16 = h-full h-16
h-8 + h-full = h-8 h-full
h-8 + h-auto = h-auto
h-auto + h-16 = h-16
h-auto + h-full = h-auto h-full
h-full + h-auto = h-full h-auto
h-8 + h-16 = h-16
h-full + h-16 = h-16
h-8 + h-full = h-full
h-8 + h-auto = h-auto
h-auto + h-16 = h-16
h-auto + h-full = h-full
h-full + h-auto = h-auto

To Reproduce

tailwind.config.js example:

export default {
   ...,
  spacing: {
    8: '.8rem',
    16: '.16rem'
  }
}

Merge code example:

const twMerge = extendTailwindMerge({
    "override":{
        "theme":{
            "spacing":[
                "8","16",
                // // Remove the comment below to fix the bug
                // "full"
            ],
        }
    }
});
twMerge('w-8', 'w-full'); // result: w-8 w-full
twMerge('w-auto', 'w-full'); // result: w-auto w-full

Steps to reproduce the behavior

https://codesandbox.io/p/sandbox/hungry-wu-636mq5?file=%2Fsrc%2Findex.ts

Expected behavior

I would expect the tailwind default auto and full spacings, that are both still available with a custom config, to behave the same in twMerge.

Environment

Windows 11, Node 20.10.0

  • tailwind-merge version: 2.2.1

Additional context

We have temporarily fixed this bug by manually adding the full spacing to our extendTailwindMerge config.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcontext-v2Related to tailwind-merge v2

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions