Skip to content

Conversation

@adamwathan
Copy link
Member

This is just a test of using Claude Code in the Cloud, not really planning to merge this but very curious to see how it did!

This was my prompt:

Create a new set of utilities called radius-* that duplicate the existing rounded-* utilities but in that new namespace, and treat the old utilities as legacy/deprecated. I'm pretty sure there's somewhere in the codebase where legacy utilities are handles separately from regular ones so they aren't suggested in IntelliSense and stuff.

Make the new utilities also support the spacing scale, so radius-4 would be border-radius: 1rem. Make sure to support all four corners, just left, just top, just bottom right, etc. like we do with other things.

Most of this work should be just in the tailwindcss package (this is a monorepo so there are multiple packages). Make sure to add tests, try to follow existing testing conventions as much as possible.


Introduce new radius-* utilities that support both the --radius theme and the spacing scale (e.g., radius-4 = calc(--spacing * 4)).

  • Add radius-* utilities with all corner variants (radius-t, radius-tl, etc.)
  • Support spacing scale values (radius-4, radius-0.5, etc.)
  • Support px values (radius-px)
  • Move rounded-* utilities to legacy-utilities.ts
  • Mark rounded-* utilities as legacy (hidden from IntelliSense suggestions)
  • Add comprehensive tests for both new and legacy utilities

Introduce new `radius-*` utilities that support both the `--radius` theme
and the spacing scale (e.g., `radius-4` = `calc(--spacing * 4)`).

- Add `radius-*` utilities with all corner variants (radius-t, radius-tl, etc.)
- Support spacing scale values (radius-4, radius-0.5, etc.)
- Support px values (radius-px)
- Move `rounded-*` utilities to legacy-utilities.ts
- Mark `rounded-*` utilities as legacy (hidden from IntelliSense suggestions)
- Add comprehensive tests for both new and legacy utilities
@adamwathan adamwathan requested a review from a team as a code owner January 3, 2026 22:39
@coderabbitai
Copy link

coderabbitai bot commented Jan 3, 2026

Walkthrough

This pull request adds legacy support for rounded utilities and refactors radius utilities in Tailwind CSS. A new ROUNDED_UTILITIES constant maps legacy rounded utility names to their CSS properties and is registered through registerLegacyUtilities. The utilities.ts file renames rounded-* utilities to radius-* and extends them to support spacing-based values, including new static utilities for 1px declarations per radius root. Legacy utilities handle edge cases like arbitrary values, 'none', and 'full' keywords. Comprehensive test coverage is added for both legacy and modern utilities, validating CSS output for radius variants and complex property parsing scenarios.

Pre-merge checks

✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Add radius utilities and deprecate rounded' directly and clearly summarizes the main changes in the pull request.
Description check ✅ Passed The description is related to the changeset, detailing the new radius utilities, spacing scale support, legacy handling, and test additions.

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 (2)
packages/tailwindcss/src/compat/legacy-utilities.ts (1)

133-165: Consider adding a type assertion for value on line 163.

The logic is correct, but TypeScript may not narrow the type of value after the early returns in the conditional blocks. While this works at runtime, a non-null assertion could make the intent clearer.

🔎 Proposed change
       if (value === null) return
 
-      return properties.map((property) => decl(property, value))
+      return properties.map((property) => decl(property, value!))
     })
   }

Alternatively, this might already work correctly if TypeScript's control flow analysis handles it—you can verify by checking if there are any type errors in CI.

packages/tailwindcss/src/utilities.test.ts (1)

11139-12159: Comprehensive test coverage for all radius variants.

The tests correctly validate all 14 directional variants with proper CSS property mappings:

  • Logical properties (radius-s, radius-e, radius-ss, radius-se, radius-ee, radius-es)
  • Physical properties (radius-t, radius-r, radius-b, radius-l, radius-tl, radius-tr, radius-br, radius-bl)

Consider adding fractional spacing test.

The PR description mentions support for fractional spacing values (e.g., radius-0.5), but this case isn't covered in the tests. Consider adding a test case for fractional values to validate this functionality.

Example addition to the base radius test
 test('radius', async () => {
   expect(
     await compileCss(
       css`
         @theme {
           --spacing: 0.25rem;
           --radius-sm: 0.125rem;
           --radius: 0.25rem;
         }
         @tailwind utilities;
       `,
-      ['radius', 'radius-full', 'radius-none', 'radius-sm', 'radius-4', 'radius-px', 'radius-[4px]'],
+      ['radius', 'radius-full', 'radius-none', 'radius-sm', 'radius-4', 'radius-0.5', 'radius-px', 'radius-[4px]'],
     ),
   ).toMatchInlineSnapshot(`
     ...
+    .radius-0\\.5 {
+      border-radius: calc(var(--spacing) * .5);
+    }
     ...
   `)
📜 Review details

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9720692 and 50f5d58.

⛔ Files ignored due to path filters (1)
  • packages/tailwindcss/src/__snapshots__/intellisense.test.ts.snap is excluded by !**/*.snap
📒 Files selected for processing (4)
  • packages/tailwindcss/src/compat/legacy-utilities.test.ts
  • packages/tailwindcss/src/compat/legacy-utilities.ts
  • packages/tailwindcss/src/utilities.test.ts
  • packages/tailwindcss/src/utilities.ts
🧰 Additional context used
🧬 Code graph analysis (4)
packages/tailwindcss/src/compat/legacy-utilities.test.ts (1)
packages/tailwindcss/src/test-utils/run.ts (1)
  • compileCss (4-11)
packages/tailwindcss/src/utilities.test.ts (3)
packages/tailwindcss/src/test-utils/custom-serializer.ts (1)
  • test (10-12)
packages/tailwindcss/src/test-utils/run.ts (2)
  • compileCss (4-11)
  • run (13-16)
packages/tailwindcss/src/index.test.ts (1)
  • test (11-236)
packages/tailwindcss/src/utilities.ts (3)
packages/tailwindcss/src/ast.ts (1)
  • decl (95-102)
packages/tailwindcss/src/utils/infer-data-type.ts (1)
  • isValidSpacingMultiplier (356-358)
packages/tailwindcss/src/variants.ts (1)
  • suggest (195-197)
packages/tailwindcss/src/compat/legacy-utilities.ts (2)
integrations/utils.ts (1)
  • candidate (534-544)
packages/tailwindcss/src/ast.ts (1)
  • decl (95-102)
🔇 Additional comments (7)
packages/tailwindcss/src/utilities.ts (1)

2175-2214: LGTM! Clean migration from rounded-* to radius-* with spacing scale support.

The implementation correctly:

  • Renames utilities to the new radius-* namespace
  • Adds support for spacing-based values via handleBareValue
  • Provides appropriate suggestions based on theme availability
  • Adds the {root}-px static utility following the established spacingUtility pattern

The handleBareValue logic mirrors the pattern in spacingUtility (lines 545-550), ensuring consistency across the codebase.

packages/tailwindcss/src/compat/legacy-utilities.test.ts (3)

215-267: Good test coverage for the legacy rounded utility.

The test correctly validates:

  • Default value resolution (roundedvar(--radius))
  • Named theme values (rounded-sm)
  • Arbitrary values (rounded-[4px])
  • Special values (rounded-none, rounded-full)
  • Negative test cases ensuring invalid variants produce no output

269-316: Test covers logical property variants well.

The rounded-s test properly validates that both border-start-start-radius and border-end-start-radius are set, matching the implementation in ROUNDED_UTILITIES.


318-360: Test coverage for physical corner variant is complete.

The rounded-tl test validates single-corner border-radius behavior correctly.

packages/tailwindcss/src/compat/legacy-utilities.ts (2)

5-21: LGTM! Clean mapping of legacy utility names to CSS properties.

The mapping correctly mirrors the property associations from the new radius-* utilities in utilities.ts, ensuring backward compatibility.


145-156: The fallback logic for none and full correctly handles missing theme values.

When --radius-none or --radius-full aren't defined in the theme, the fallback to static values (0 and calc(infinity * 1px)) ensures the utilities still work as expected. This matches the behavior in the new radius-* utilities' staticValues (lines 2203-2204 in utilities.ts).

packages/tailwindcss/src/utilities.test.ts (1)

11054-11137: Solid test coverage for base radius utility.

The test correctly validates:

  • Fallback behavior for radius-full (using max float 3.40282e38px) when --radius-full is not defined in the theme
  • Theme variable override when --radius-full is explicitly defined (lines 11102-11120)
  • Spacing-based values via calc(var(--spacing) * 4)
  • Rejection of negative values and modifier syntax

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.

3 participants