From 90a2373620200bf7e04d1d228a0d0a1c506e532a Mon Sep 17 00:00:00 2001 From: Robin Malfait Date: Fri, 8 May 2026 21:15:59 +0200 Subject: [PATCH] add `zoom-*` utilities (#20020) This PR adds new `zoom-*` utilities. The `zoom-*` utilities accept bare values that are transformed into `%` based values, and arbitrary values: | Class | CSS | | -- | -- | | `zoom-50` | `zoom: 50%;` | | `zoom-[1.1]` | `zoom: 1.1;` | | `zoom-(--value)` | `zoom: var(--value);` | 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 --- CHANGELOG.md | 1 + .../__snapshots__/intellisense.test.ts.snap | 10 +++++++ packages/tailwindcss/src/property-order.ts | 2 ++ packages/tailwindcss/src/utilities.test.ts | 28 +++++++++++++++++++ packages/tailwindcss/src/utilities.ts | 15 ++++++++++ 5 files changed, 56 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b2b1ecb51..fd441caaa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Allow using `@variant` with stacked variants (e.g. `@variant hover:focus { … }`) ([#19996](https://github.com/tailwindlabs/tailwindcss/pull/19996)) - Allow using `@variant` with compound variants (e.g. `@variant hover, focus { … }`) ([#19996](https://github.com/tailwindlabs/tailwindcss/pull/19996)) - Support `--default(…)` in `--value(…)` and `--modifier(…)` for functional `@utility` definitions ([#19989](https://github.com/tailwindlabs/tailwindcss/pull/19989)) +- Add `zoom-*` utilities ([#20020](https://github.com/tailwindlabs/tailwindcss/pull/20020)) - Add `scrollbar-gutter-*` utilities ([#20018](https://github.com/tailwindlabs/tailwindcss/pull/20018)) ### Fixed diff --git a/packages/tailwindcss/src/__snapshots__/intellisense.test.ts.snap b/packages/tailwindcss/src/__snapshots__/intellisense.test.ts.snap index b281e0f98..01636618d 100644 --- a/packages/tailwindcss/src/__snapshots__/intellisense.test.ts.snap +++ b/packages/tailwindcss/src/__snapshots__/intellisense.test.ts.snap @@ -12247,6 +12247,16 @@ exports[`getClassList 1`] = ` "z-40", "z-50", "z-auto", + "zoom-50", + "zoom-75", + "zoom-90", + "zoom-95", + "zoom-100", + "zoom-105", + "zoom-110", + "zoom-125", + "zoom-150", + "zoom-200", ] `; diff --git a/packages/tailwindcss/src/property-order.ts b/packages/tailwindcss/src/property-order.ts index 0fa99cc53..016200c6c 100644 --- a/packages/tailwindcss/src/property-order.ts +++ b/packages/tailwindcss/src/property-order.ts @@ -92,6 +92,8 @@ export default [ '--tw-skew-y', 'transform', + 'zoom', + 'animation', 'cursor', diff --git a/packages/tailwindcss/src/utilities.test.ts b/packages/tailwindcss/src/utilities.test.ts index 492986e83..b2873294d 100644 --- a/packages/tailwindcss/src/utilities.test.ts +++ b/packages/tailwindcss/src/utilities.test.ts @@ -6899,6 +6899,34 @@ test('transform', async () => { ).toEqual('') }) +test('zoom', async () => { + expect( + await compileCss( + css` + @tailwind utilities; + `, + ['zoom-50', 'zoom-100', 'zoom-[var(--zoom)]'], + ), + ).toMatchInlineSnapshot(` + " + .zoom-50 { + zoom: 50%; + } + + .zoom-100 { + zoom: 100%; + } + + .zoom-\\[var\\(--zoom\\)\\] { + zoom: var(--zoom); + } + " + `) + expect( + await run(['zoom', '-zoom-50', 'zoom--50', 'zoom-1.5', 'zoom-unknown', 'zoom-50/foo']), + ).toEqual('') +}) + test('perspective', async () => { expect( await compileCss( diff --git a/packages/tailwindcss/src/utilities.ts b/packages/tailwindcss/src/utilities.ts index 599cfc0c5..74e39ee5f 100644 --- a/packages/tailwindcss/src/utilities.ts +++ b/packages/tailwindcss/src/utilities.ts @@ -1706,6 +1706,21 @@ export function createUtilities(theme: Theme) { staticUtility('transform-none', [['transform', 'none']]) } + /** + * @css `zoom` + */ + functionalUtility('zoom', { + handleBareValue: ({ value }) => { + if (!isPositiveInteger(value)) return null + return `${value}%` + }, + handle: (value) => [decl('zoom', value)], + }) + + suggest('zoom', () => [ + { values: ['50', '75', '90', '95', '100', '105', '110', '125', '150', '200'] }, + ]) + /** * @css `transform-style` */