Skip to content

Canonicalization merges theme variables with equal defaults but different dark-mode overrides #20539

Closed

Description

@ftes

What version of Tailwind CSS are you using?

v4.3.3

What build tool (or framework if it abstracts the build tool) are you using?

esbuild v0.27.2

What version of Node.js are you using?

v26.10.0

What browser are you using?

Chrome

What operating system are you using?

macOS

Reproduction

@import "tailwindcss" source(none);

@theme {
  --color-foreground: black;
  --color-primary: red;
  --color-card-checked-border: red;
}

@layer base {
  .dark {
    --color-primary: blue;
    --color-card-checked-border: red;
  }
}
tailwindcss canonicalize --css input.css \
  'text-foreground text-primary'

Describe your issue

Canonicalization replaces a text-color utility with another theme token that matches in the default theme but differs in dark mode.

Actual behavior: Outputs text-card-checked-border. This changes dark-mode text from blue to red.
Expected behavior: Return text-primary, or preserve the original pair. In the original pair, text-primary wins the CSS cascade.

Canonicalizing text-primary alone leaves it unchanged. The problematic replacement happens when collapsing the conflicting pair.

Activity

  1. added a commit that references this issue on Oct 14, 2026
    d4b5c63
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions