Skip to content

Conversation

@thecrypticace
Copy link
Contributor

Fixes #19345

In v3 the ringColor.DEFAULT option was used as the default color for ring utilities (when it was defined). This currently gets translated as --ring-color but that doesn't work this way in v4. Instead it should translate to --default-ring-color and not --ring-color.

I've also tweaked the upgrade tool to handle this properly as well.

@thecrypticace thecrypticace requested a review from a team as a code owner November 20, 2025 23:46
@coderabbitai
Copy link

coderabbitai bot commented Nov 20, 2025

Walkthrough

Adds handling for DEFAULT theme keys (e.g., ringColor.DEFAULT) so they map to --default-<name> CSS variables (example: --default-ring-color). Introduces SPECIAL_DEFAULT_KEYS and OLD_TO_NEW_NAMESPACE mappings in the key-to-CSS-property logic and skips legacy container processing. Updates tests and changelog to reflect new defaults. Changes the codemod to emit an initial namespace reset only when a computed property exists, the key is not default--prefixed, and the namespace has not yet been reset.

Pre-merge checks

✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: handling ringColor.DEFAULT in JavaScript configs, which is the primary focus of the changeset.
Description check ✅ Passed The description is directly related to the changeset, explaining the issue, the v3 vs v4 behavior difference, and the upgrade tool fix.
Linked Issues check ✅ Passed The PR successfully addresses #19345 by implementing the required migration of ringColor.DEFAULT to --default-ring-color in both the main config handler and upgrade tool.
Out of Scope Changes check ✅ Passed All changes are directly related to handling ringColor.DEFAULT translation and migration; no unrelated modifications are present in the changeset.

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 22d3cb2 and f598f1e.

📒 Files selected for processing (1)
  • integrations/upgrade/index.test.ts (2 hunks)
🔇 Additional comments (3)
integrations/upgrade/index.test.ts (3)

84-84: LGTM! Test expectations correctly updated.

The migration from ring to ring-3 is consistent with the new DEFAULT handling for ringWidth.

Also applies to: 122-122


2383-2383: LGTM! Consistent test expectations.

All test cases consistently expect ring to migrate to ring-3, ensuring the upgrade behavior is reliable across different scenarios.

Also applies to: 2760-2760, 2829-2829, 2872-2872


2350-2350: Based on my verification, I have found the following:

Verification Results:

  • ringColor.DEFAULT is NOT tested in integrations/upgrade/index.test.ts
  • ringColor.DEFAULT IS tested in integrations/upgrade/js-config.test.ts (lines 37-38 config mapping to line 197 expected output: --default-ring-color: #c0ffee;)
  • ringWidth.DEFAULT is tested in integrations/upgrade/index.test.ts (line 2295-2297, output at line 2350)
  • Both are handled as "special defaults" per the codebase documentation in apply-config-to-theme.ts (line 179-183)

The original review's concern is valid: there is a coverage gap for ringColor.DEFAULT in the specific test file being reviewed. However, ringColor.DEFAULT migration is covered by tests in a different integration test file (js-config.test.ts), suggesting this may be a deliberate division of test coverage rather than a complete oversight.


Verify test coverage for ringColor.DEFAULT in this file.

The test correctly validates that ringWidth.DEFAULT migrates to --default-ring-width: 4px;. However, no test case in this file covers ringColor.DEFAULT migration to --default-ring-color, even though both are special defaults handled identically by the upgrade logic. While ringColor.DEFAULT is tested in integrations/upgrade/js-config.test.ts, consider whether this specific test scope should include ringColor.DEFAULT for parity with ringWidth.DEFAULT coverage in the same file.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/@tailwindcss-upgrade/src/codemods/config/migrate-js-config.ts (1)

240-246: Migration of ringColor.DEFAULT to --default-ring-color looks correct

The upgrade path now emits --default-ring-color for ringColor.DEFAULT and skips the generic keyPathToCssProperty mapping, keeping the generated CSS consistent with the runtime theme behavior and avoiding an incorrect --ring-color variable.

If we add more special-cased theme keys in future, consider centralizing this mapping so apply-config-to-theme and the upgrader can’t drift apart.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 479b725 and 301ef64.

📒 Files selected for processing (5)
  • CHANGELOG.md (1 hunks)
  • integrations/upgrade/js-config.test.ts (2 hunks)
  • packages/@tailwindcss-upgrade/src/codemods/config/migrate-js-config.ts (1 hunks)
  • packages/tailwindcss/src/compat/apply-config-to-theme.test.ts (2 hunks)
  • packages/tailwindcss/src/compat/apply-config-to-theme.ts (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
packages/@tailwindcss-upgrade/src/codemods/config/migrate-js-config.ts (1)
packages/tailwindcss/src/utils/escape.ts (1)
  • escape (2-73)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Linux / upgrade
  • GitHub Check: Linux / vite
  • GitHub Check: Linux / postcss
  • GitHub Check: Linux
🔇 Additional comments (5)
CHANGELOG.md (1)

18-18: Changelog entry correctly describes the ringColor.DEFAULT fix

The new “Fixed” bullet is accurate, scoped, and links to the correct PR, so the release notes will clearly communicate this behavior change.

packages/tailwindcss/src/compat/apply-config-to-theme.ts (1)

53-63: Special-case for ringColor.DEFAULT--default-ring-color is correct and consistent

Handling ringColor.DEFAULT before the generic keyPathToCssProperty path ensures we no longer emit --ring-color and instead populate --default-ring-color with the right theme options, matching the intended v3-compatible behavior.

packages/tailwindcss/src/compat/apply-config-to-theme.test.ts (1)

60-63: Tests accurately cover the new default ring color behavior

Adding ringColor.DEFAULT to the test config and asserting that --ring-color is unset while --default-ring-color is '#fff' validates the new mapping end-to-end and guards against regressions.

Also applies to: 132-133

integrations/upgrade/js-config.test.ts (2)

37-39: LGTM! Test input properly configured.

The ringColor.DEFAULT configuration correctly sets up the test case for validating the v3 to v4 migration behavior. The test value #c0ffee is clearly identifiable in the output.


197-198: LGTM! Expected output correctly validates the migration.

The test properly verifies that ringColor.DEFAULT migrates to --default-ring-color (not --ring-color), which aligns with the PR objectives. The snapshot-based assertion implicitly confirms that the old --ring-color variable does not appear in the output.

Comment on lines 53 to 63
// ringColor.DEFAULT is a special case that maps to `--default-ring-color`
// as to match the behavior of v3
if (path[0] === 'ringColor' && path[1] === 'DEFAULT') {
designSystem.theme.add(
'--default-ring-color',
'' + value,
ThemeOptions.INLINE | ThemeOptions.REFERENCE | ThemeOptions.DEFAULT,
)

continue
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit confused why this is handled in isolation here since we had a lot of other DEFAULT special keys that are supported in v4 too via the --default-* pattern, e.g.: --default-ring-width, --default-outline-width, --default-transition-duration. So I'd expect there to a code path a bit more generic to handle all of these variants.

From my quick look it seems that we didn't handle this in apply-config-to-theme at all right now so not sure if this is an oversight or if there's an alternative explanation?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah this is a good point. We do handle a few default things with regards to fonts but nothing else. Lemme do a bit of poking around to see if we need to handle a few more things.

There’s a few namespaces that need special behavior

Handle more default conversions
This is just to make the code a bit nicer and consistent
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Upgrade tool doesn't migrate ringColor.DEFAULT correctly

3 participants