Repository navigation
feat(compiler): compile transform-origin to React Native's transformOrigin - #609
Open
jeltehomminga wants to merge 1 commit into
Open
jeltehomminga wants to merge 1 commit into
jeltehomminga wants to merge 1 commit into
Conversation
…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
Contributor
There was a problem hiding this comment.
🟢 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
5 tasks done
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #509. Thanks for saying you'd take this.
On main every
origin-*class compiles to nothing on native, with a warning. This compilestransform-originto React Native'stransformOrigininstead.Before and after
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, same layout.What it compiles to
leftandtopbecome0,centerbecomes"50%", andrightandbottombecome"100%". Lengths and percentages go through the existing length parser, sorembecomes px and25%stays"25%". z is always0.transformOriginorigin-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]calc()warningorigin-(--my-origin)Not supported
var(): React Native throws in development on atransformOriginthat isn't exactly[x, y, z], and a variable can hold any value, so avar()value keeps the warning.origin-[left_top_30px]: lightningcss readstransform-originlike a background position, so by the time the compiler sees it,left top 30pxhas become0 30px, an origin 30px down. That needs a fix in lightningcss (A three-valuetransform-originloses its z when its y is a near side:left top 30pxminifies to0 30pxparcel-bundler/lightningcss#1403), so I left it alone. Tailwind's named classes never set a z.Tests
The origin tests in
src/__tests__/vendor/tailwind/transform.test.tsnow expect the arrays for the nine named classes andorigin-[25%_10px], plus thecalc()andvar()cases. 11 of them fail on main and pass with this change.src/__tests__/metro/warnings.test.tsusedtransform-originas its example of an unsupported property, so its fixture usestext-indentnow.The full test suite,
yarn typecheckand eslint on the changed files pass.transition-property: transform-originnow passes through astransformOrigintoo, 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 nineorigin-*classes as rejected.