Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]
`;

Expand Down
2 changes: 2 additions & 0 deletions packages/tailwindcss/src/property-order.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ export default [
'--tw-skew-y',
'transform',

'zoom',

'animation',

'cursor',
Expand Down
28 changes: 28 additions & 0 deletions packages/tailwindcss/src/utilities.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
"
`)
Comment on lines +6922 to +6924
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.

expect(
await run(['zoom', '-zoom-50', 'zoom--50', 'zoom-1.5', 'zoom-unknown', 'zoom-50/foo']),
).toEqual('')
})

test('perspective', async () => {
expect(
await compileCss(
Expand Down
15 changes: 15 additions & 0 deletions packages/tailwindcss/src/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'] },
])
Comment on lines +1712 to +1722
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.

P1 The zoom utility is missing themeKeys: ['--zoom'], so user-defined @theme values like --zoom-compact: 80% cannot be resolved via the zoom-compact shorthand. Every comparable functional utility that mixes bare-value handling with optional theme tokens (opacity, z, scale-x/y/z) passes a themeKeys array. Without it, theme.resolve('compact', []) always returns null, falling through to handleBareValue, which then rejects any non-integer string — meaning zoom-compact produces no output even when --zoom-compact is defined in @theme. The PR description explicitly shows this path as a supported feature.

Suggested change
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'] },
])
functionalUtility('zoom', {
themeKeys: ['--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'],
valueThemeKeys: ['--zoom'],
},
])

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.

Removed reading from --zoom on purpose. They only exist in other utilities for backwards compatibility reasons with Tailwind CSS v3.


/**
* @css `transform-style`
*/
Expand Down