Skip to content

feat(compiler): compile transform-origin to React Native's transformOrigin - #609

Open
jeltehomminga wants to merge 1 commit into
nativewind:mainfrom
jeltehomminga:jeltehomminga/transform-origin
Open

jeltehomminga wants to merge 1 commit into
nativewind:mainfrom
jeltehomminga:jeltehomminga/transform-origin

Conversation

@jeltehomminga

Copy link
Copy Markdown

Closes #509. Thanks for saying you'd take this.

On main every origin-* class compiles to nothing on native, with a warning. This compiles transform-origin to React Native's transformOrigin instead.

Before and after

iOS simulator: the origin-* boxes on main (left) and on this branch (right) Android emulator: the origin-* boxes on main (left) and on this branch (right)

The repo's example app on an iOS 26.5 simulator (iPhone 17 Pro) and an Android 17 emulator (Pixel 10). Main on the left, this branch on the right. The dashed outline is the box before the transform, and the red dot is the origin the class sets.

origin-top-left animate-spin on main (left) and on this branch (right)

origin-top-left animate-spin, same layout.

What it compiles to

left and top become 0, center becomes "50%", and right and bottom become "100%". Lengths and percentages go through the existing length parser, so rem becomes px and 25% stays "25%". z is always 0.

Class transformOrigin
origin-top-left [0, 0, 0]
origin-top ["50%", 0, 0]
origin-center ["50%", "50%", 0]
origin-bottom-right ["100%", "100%", 0]
origin-[25%_10px] ["25%", 10, 0]
origin-[calc(100%-1px)_0] dropped, with the usual calc() warning
origin-(--my-origin) dropped, with the warning from main

Not supported

Tests

The origin tests in src/__tests__/vendor/tailwind/transform.test.ts now expect the arrays for the nine named classes and origin-[25%_10px], plus the calc() and var() cases. 11 of them fail on main and pass with this change. src/__tests__/metro/warnings.test.ts used transform-origin as its example of an unsupported property, so its fixture uses text-indent now.

The full test suite, yarn typecheck and eslint on the changed files pass. transition-property: transform-origin now passes through as transformOrigin too, but I haven't checked a transition on a device. The web build doesn't go through this compiler, so nothing changes there.

If this lands, I can send the matching change to nativewind's docs/rc-compatibility.md, which lists the nine origin-* classes as rejected.

…rigin

The origin-* classes compiled to nothing on native, with a warning.
transform-origin now compiles to transformOrigin as [x, y, 0]: left and
top become 0, center becomes "50%", right and bottom become "100%".
Lengths and percentages go through the existing length parser, and
calc() drops with the usual value warning.

A var() value still drops with the warning from before, because React
Native throws in development on a transformOrigin that is not exactly
[x, y, z], and a variable can hold any value.

The metro warnings test used transform-origin as its unsupported
property; its fixture uses text-indent now.

Closes nativewind#509
Copilot AI balanced review requested due to automatic review settings December 5, 2026 12:44

Copilot AI left a comment

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.

🟢 Approval recommended

No actionable issues were found in the reviewed changes.

No open issues 🎉

What changed in this PR

Adds native transform-origin compilation, enabling NativeWind’s origin-* classes to set React Native’s transformOrigin and addressing #509.

Changes:

  • Maps origin keywords, lengths, and percentages to [x, y, 0].
  • Updates tests for supported origins and retained calc()/var() warnings.
  • Replaces the now-supported property in the unsupported-property warning fixture.
File Description
src/​compiler/​declarations.ts Adds origin parsing while retaining warnings for unparsed values.
src/​__tests__/​vendor/​tailwind/​transform.test.ts Verifies origin arrays and unsupported-value warnings.
src/​__tests__/​metro/​warnings.test.ts Uses text-indent in the unsupported-property fixture.

Review effort: Balanced

jeltehomminga added a commit to jeltehomminga/stellar-portfolio that referenced this pull request Dec 5, 2026
* OSS post: add the method loop diagram

A six-step loop (find, repro, control, short PR, review, merged), drawn in the site's colour tokens like PipelineDiagram: two rows from md up, one column on phones. Box labels are a draft until the post text is approved.

* OSS post: add the MUI X and NativeWind before/after clips

pr-clip share copies with posters: mui/mui-x#23991 (24.8 s, re-rendered with the caption fade fix) and nativewind/react-native-css#609 (28.6 s, iOS).

* OSS post: draft of the upstream fixes post

Where the fixes ship, the loop behind them, the React Native, MUI X and NativeWind stories, the smaller fixes and bug reports, a section on pull requests maintainers want to review, and how to start. Adds a Status component for each item's state line, and brings two diagram labels in line with the PRs. Draft: the text is not approved yet.

* OSS post: apply Jelte's edits to the draft

* OSS post: fit the React Native code blocks on phones

* OSS post: fit the 'Where my code ships' table on phones

The release moves to a faint second line under each fix, so the table has three columns and fits at 375 px.

* OSS post: lighter clip posters, a simpler loop diagram

The two posters were 1920 px JPEGs (298 KB) that every visitor downloads, played or not. They are 1280 px WebP now (35 KB). The diagram picks its colours and box positions from one list each; its markup is unchanged. CLAUDE.md lists MethodDiagram and Status.

* Blog tables: fit a 320 px phone without a sideways scroll

Below 640 px, table cells keep 6 px side padding instead of 12, and the first and last columns sit flush with the text. All five tables on the site fit at 320 px now; before, every one of them scrolled. Tablets and desktop are unchanged.

This branch has not been deployed

No deployments
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.

origin-* classes: would you take a PR for transformOrigin now, or after 5.0?

2 participants