Skip to content

add zoom-* utilities#20020

Open
RobinMalfait wants to merge 2 commits intomainfrom
feat/add-zoom
Open

add zoom-* utilities#20020
RobinMalfait wants to merge 2 commits intomainfrom
feat/add-zoom

Conversation

@RobinMalfait
Copy link
Copy Markdown
Member

This PR adds new zoom-* utilities.

The zoom-* utilities accept bare values that are transformed into % based values. They support arbitrary values, and support theme values coming from --zoom-*:

Class CSS
zoom-50 zoom: 50%;
zoom-[1.1] zoom: 1.1;
zoom-(--value) zoom: var(--value);
@theme {
  --zoom-compact: 80%;
}

zoom-compact:

.zoom-compact {
  zoom: var(--zoom-compact);
}

This doesn't ship with any --zoom-* theme keys out of the box.

This also adds the zoom property after the transform related properties. Initially I added it right after scale, because logically they are close together. But then zoom-* would sit between scale and other tranfsorm related properties which is a bit weird. Instead, I moved it after transform.

Test plan

  1. Added new zoom based tests
  2. All other tests still pass

@RobinMalfait RobinMalfait requested a review from a team as a code owner May 7, 2026 09:54
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 7, 2026

Confidence Score: 5/5

Safe to merge — the change is a self-contained additive utility with no modifications to existing behaviour.

The new zoom utility is a straightforward additive feature. It follows the exact same implementation pattern as the many existing percentage-based utilities (scale, brightness, contrast, etc.), uses the same isPositiveInteger guard, and does not touch any shared logic. Tests cover themed, bare, and arbitrary values as well as negative/invalid rejection. No existing utilities or their outputs are altered.

No files require special attention.

Reviews (2): Last reviewed commit: "update changelog" | Re-trigger Greptile

Comment on lines +6929 to +6935
}

.zoom-compact {
zoom: var(--zoom-compact);
}
"
`)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Arbitrary decimal number case not tested

The PR description explicitly shows zoom-[1.1]zoom: 1.1 as a supported form, but the test only exercises zoom-[var(--zoom)] for arbitrary values. A <number> arbitrary value (e.g. zoom-[1.1], zoom-[0.8]) is the natural way to express sub-100% zoom without percent syntax and should be covered to confirm the arbitrary path passes the value through unchanged.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Sure, but any value in […] is emitted as-is, so the result would be the same.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 7, 2026

Review Change Stack
No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: cd9ffc35-7769-4bdd-b31d-fe7e118253ab

📥 Commits

Reviewing files that changed from the base of the PR and between 0c1893c and 289765c.

⛔ Files ignored due to path filters (1)
  • packages/tailwindcss/src/__snapshots__/intellisense.test.ts.snap is excluded by !**/*.snap
📒 Files selected for processing (4)
  • CHANGELOG.md
  • packages/tailwindcss/src/property-order.ts
  • packages/tailwindcss/src/utilities.test.ts
  • packages/tailwindcss/src/utilities.ts
✅ Files skipped from review due to trivial changes (2)
  • packages/tailwindcss/src/utilities.test.ts
  • CHANGELOG.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/tailwindcss/src/property-order.ts

Hidden review stack artifact

Walkthrough

This PR adds a new zoom CSS utility that maps zoom-{n}/theme keys/arbitrary values to the zoom CSS property, converts bare positive integer inputs to percentages, registers completion suggestions for common percentages, inserts zoom into the property order immediately after transform, includes tests for generated classes and invalid inputs, and adds a changelog entry.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'add zoom-* utilities' directly and clearly summarizes the main change: introducing new zoom utility classes to the Tailwind CSS framework.
Description check ✅ Passed The description comprehensively explains the zoom utilities, their syntax, theme support, examples, property ordering rationale, and test coverage—all directly related to the changeset.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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

Copy link
Copy Markdown
Contributor

@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.

🧹 Nitpick comments (3)
packages/tailwindcss/src/utilities.ts (2)

1721-1726: ⚡ Quick win

'0' is absent from the zoom suggest values.

scale's suggest block includes '0' (which maps to scale: 0 / scale-0). Since zoom: 0% is valid CSS (renders the element invisible, useful for enter/exit animations), and isPositiveInteger treats '0' as a valid input elsewhere in this file (e.g., z index), zoom-0 should be a supported value. Omitting it from the completions list means IDEs and tooling won't surface it as a suggestion.

💡 Proposed fix
  suggest('zoom', () => [
    {
-     values: ['50', '75', '90', '95', '100', '105', '110', '125', '150', '200'],
+     values: ['0', '50', '75', '90', '95', '100', '105', '110', '125', '150', '200'],
      valueThemeKeys: ['--zoom'],
    },
  ])
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/tailwindcss/src/utilities.ts` around lines 1721 - 1726, The suggest
list for zoom is missing the '0' option; update the suggest('zoom', ...) block
(the values array in that call) to include '0' alongside the existing
percentages so IDEs surface zoom-0; modify the values array in the
suggest('zoom', () => [...]) entry (and ensure valueThemeKeys ['--zoom'] remains
unchanged) to add '0' as a valid completion.

1709-1727: Consider adding zoom to the default transition-property list.

The default transition value (Line 4712) covers transform, translate, scale, rotate but not zoom. Since zoom is now a first-class utility, users applying transition zoom-50 hover:zoom-100 will be surprised that transition alone doesn't include it. This is analogous to how scale is included.

This is an architectural decision for the PR author to evaluate — it's a separate change from the utility registration, but worth deciding before shipping so the API is complete from day one.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/tailwindcss/src/utilities.ts` around lines 1709 - 1727, The default
transition-property list currently omits "zoom", so add "zoom" to the default
transition property set (the same place the existing defaults for "transform,
translate, scale, rotate" are defined) so that utilities like transition and
classes like hover:zoom-100 animate as expected; update the default transition
property constant/array (where the default transition value is assembled) to
include "zoom" and run/update any related tests/docs that assert the default
transition-property list.
packages/tailwindcss/src/utilities.test.ts (1)

6902-6939: ⚡ Quick win

Add coverage for documented zoom-[1.1] and zoom-(--value) syntaxes

Line 6902 introduces good coverage, but the two syntaxes called out in the PR description are not asserted here. Adding them would better lock behavior to the documented contract.

Proposed test extension
 test('zoom', async () => {
   expect(
     await compileCss(
       css`
         `@theme` {
           --zoom-compact: 80%;
         }
         `@tailwind` utilities;
       `,
-      ['zoom-50', 'zoom-100', 'zoom-[var(--zoom)]', 'zoom-compact'],
+      [
+        'zoom-50',
+        'zoom-100',
+        'zoom-[1.1]',
+        'zoom-[var(--zoom)]',
+        'zoom-(--value)',
+        'zoom-compact',
+      ],
     ),
   ).toMatchInlineSnapshot(`
     "
@@
     .zoom-100 {
       zoom: 100%;
     }

+    .zoom-\\[1\\.1\\] {
+      zoom: 1.1;
+    }
+
     .zoom-\\[var\\(--zoom\\)\\] {
       zoom: var(--zoom);
     }
 
+    .zoom-\\(--value\\) {
+      zoom: var(--value);
+    }
+
     .zoom-compact {
       zoom: var(--zoom-compact);
     }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/tailwindcss/src/utilities.test.ts` around lines 6902 - 6939, The
"zoom" test lacks assertions for the documented syntaxes `zoom-[1.1]` and
`zoom-(--value)`; update the test named "zoom" to include those classnames when
calling compileCss and run so the compiled output and runtime filter are
verified: add 'zoom-[1.1]' and 'zoom-(--value)' to the compileCss class list and
to the run([...]) input, and assert the compiled CSS contains the corresponding
rules (an escaped selector for the bracket form mapping to zoom:1.1 and an
escaped selector for the parenthesis/variable form mapping to zoom:var(--value))
so the test locks the documented behavior for compileCss and run.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@packages/tailwindcss/src/utilities.test.ts`:
- Around line 6902-6939: The "zoom" test lacks assertions for the documented
syntaxes `zoom-[1.1]` and `zoom-(--value)`; update the test named "zoom" to
include those classnames when calling compileCss and run so the compiled output
and runtime filter are verified: add 'zoom-[1.1]' and 'zoom-(--value)' to the
compileCss class list and to the run([...]) input, and assert the compiled CSS
contains the corresponding rules (an escaped selector for the bracket form
mapping to zoom:1.1 and an escaped selector for the parenthesis/variable form
mapping to zoom:var(--value)) so the test locks the documented behavior for
compileCss and run.

In `@packages/tailwindcss/src/utilities.ts`:
- Around line 1721-1726: The suggest list for zoom is missing the '0' option;
update the suggest('zoom', ...) block (the values array in that call) to include
'0' alongside the existing percentages so IDEs surface zoom-0; modify the values
array in the suggest('zoom', () => [...]) entry (and ensure valueThemeKeys
['--zoom'] remains unchanged) to add '0' as a valid completion.
- Around line 1709-1727: The default transition-property list currently omits
"zoom", so add "zoom" to the default transition property set (the same place the
existing defaults for "transform, translate, scale, rotate" are defined) so that
utilities like transition and classes like hover:zoom-100 animate as expected;
update the default transition property constant/array (where the default
transition value is assembled) to include "zoom" and run/update any related
tests/docs that assert the default transition-property list.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 13235977-428f-40e3-8a43-e670c55a3b32

📥 Commits

Reviewing files that changed from the base of the PR and between 12eb5ae and 0c1893c.

⛔ Files ignored due to path filters (1)
  • packages/tailwindcss/src/__snapshots__/intellisense.test.ts.snap is excluded by !**/*.snap
📒 Files selected for processing (4)
  • CHANGELOG.md
  • packages/tailwindcss/src/property-order.ts
  • packages/tailwindcss/src/utilities.test.ts
  • packages/tailwindcss/src/utilities.ts

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.

1 participant