Repository navigation
feat(transforms): read rotate by its own grammar, and none from a var() - #600
Open
YevheniiKotyrlo wants to merge 1 commit into
Open
YevheniiKotyrlo wants to merge 1 commit into
YevheniiKotyrlo wants to merge 1 commit into
Conversation
The individual transform properties each have a grammar of their own
(css-transforms-2 §3), which the transform function of the same name
doesn't share. The transform-properties fix keeps the part Tailwind
reaches, an optional z on translate and scale. This adds the rest:
- rotate takes an axis keyword or a vector beside its angle, in either
order, written or substituted from a var(). A rotation turns about the
axis its vector names, reversed about a negative axis, and the zero
vector rotates by none:
rotate: 0 0 -1 45deg -> [{ rotateZ: "-45deg" }]
--r: x 45deg; rotate: var(--r) -> [{ rotateX: "45deg" }]
rotate: 0 0 0 45deg -> [{ rotateZ: "0deg" }]
The compiler and the runtime share that decision through rotationAxis()
in react-native-css/utilities. React Native's rotate keys turn only
about an axis, so a vector off every axis warns and is ignored when
written, and is none when substituted.
- A rotate from a var() renders as rotateZ, as a written one does.
- translate, rotate and scale read none substituted from a var() as the
identity.
- A written scale along z warns, as React Native has no z axis to scale
along.
This was split out of nativewind#389 because Tailwind never reaches it: its
utilities write rotate: <angle> and none literally.
YevheniiKotyrlo
force-pushed
the
feat/rotate-longhand-grammar
branch
from
December 2, 2026 16:53
df5b62a to
2cd2546
Compare
YevheniiKotyrlo
marked this pull request as ready for review
December 2, 2026 16:54
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.
Problem
translate,rotateandscaleeach have a grammar of their own (css-transforms-2, individual transforms), which the transform function of the same name doesn't share. #576 keeps the part Tailwind reaches, an optional z ontranslateandscale. The rest only comes up in CSS written by hand:mainrotate: 0 0 -1 45deg(negative axis)rotateZ: "45deg", the wrong wayrotateZ: "-45deg"rotate: -1 0 0 45degrotateX: "45deg", the wrong wayrotateX: "-45deg"rotate: 0 0 0 45deg(zero vector)rotatekeyrotateZ: "0deg"rotate: 1 1 0 45deg(oblique)rotateXandrotateY, two rotations--r: x 45deg; rotate: var(--r)rotateX: "45deg"--r: 45deg y; rotate: var(--r)rotateY: "45deg"--r: x; rotate: var(--r) 45degrotateX: "45deg"scale: 2 3 400%(z ≠ 1)These render the same either way, in a different shape:
main--r: 20deg; rotate: var(--r)rotate: "20deg"rotateZ: "20deg", as a writtenrotate:--t: none; translate: var(--t)translateX: 0,translateY: 0--s: none; scale: var(--s)scaleX: 1,scaleY: 1--r: none; rotate: var(--r)rotateZ: "0deg"Browsers draw an oblique
rotateas one rotation about that vector and apply ascalealong z. React Native's rotate keys turn only about an axis and it has no z to scale along, so this PR warns for both rather than render something else.Solution
individualRotatereads an angle, with an axis keyword or three numbers beside it, in either order.rotationAxis()inreact-native-css/utilitiesdecides the axis andnegateAngle()flips the angle for a negative one, so the compiler'sparseRotateand the runtime agree. An oblique vector warns when written and isnonewhen substituted.individualTranslate,individualScaleandindividualRotateread anonesubstituted from avar()as the identity.parseScalewarns for a z other than 1.Split out of #389, whose transform-properties fix landed in #576.
Tests
src/__tests__/native/transform.test.tsx: therotateandnonerows above, written and through avar(), andtransform: var(--missing)replacing an earlier rule's transform.src/__tests__/compiler/compiler.test.tsx: "a scale along z or a rotate about an oblique axis warns".src/__tests__/native/variable-fold-parity.test.tsx:rotateread through avar()now matches the compiler'srotateZ, so its known-divergence entry goes.Verification
A local replica of CI passes every job on Node 26.12.1, where
.nvmrcpins 24.22.3: lint and typecheck,yarn test --maxWorkers=2 --coverage(2254 passed), the library build withnode --test, the web export and commitlint in Ubuntu, and the iOS dev build on macOS with Xcode 27.2, whereci.ymlpins 26.6.The runtime cost is not measured on Hermes. Every runtime
translateandscalenow checks fornone, one comparison each; the axis parsing runs only for arotateread through avar().