Skip to content

Class conflicts in Shell.Cn aren't resolved (tailwind-merge) #51

Closed

Description

@Shewart

Summary

Shell.Cn joins class strings but doesn't resolve Tailwind conflicts, so a consumer's Class can't reliably override a component's default. Class="max-w-2xl" on a component that already has max-w-sm leaves both classes, and which one wins depends on the order in the generated CSS, not on the order written.

Steps to reproduce

<SheetContent Class="sm:max-w-2xl">...</SheetContent>

Expected: the sheet is max-w-2xl wide.
Actual: it stays max-w-sm. The workaround today is Tailwind's important modifier (sm:max-w-2xl!).

Suggested fix

Port the core of tailwind-merge to Shell.Cn: group utilities by what they set (max-w-*, p-*/px-*, colours, …) including variants (sm:, hover:), and keep the last class in each group. Start with the groups components set by default (sizing, spacing, colours, borders, radius) and cover them with unit tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions