Tailwind CSS Handbook v4.3

Transforms

Translate, scale, rotate and skew — plus the 3D transform utilities and perspective added in Tailwind v4.

Transforms move, resize and rotate an element without affecting document layout, which makes them the cheapest way to animate anything.

2D transforms#

UtilityEffect
translate-x-4 / translate-y-4Move along an axis
translate-4Move on both axes
-translate-y-1Negative — move up
translate-x-1/2Percentage of the element's own size
scale-110Scale both axes to 110%
scale-x-75 / scale-y-150Per-axis
rotate-45 / -rotate-12Rotate in degrees
skew-x-6 / skew-y-3Skew
transform-noneRemove all transforms
Loading preview…

Transforms compose — translate-x-2 rotate-3 scale-105 applies all three.

Transform origin#

By default transforms pivot around the centre. origin-* changes that.

UtilityOrigin
origin-centerDefault
origin-top origin-bottom origin-left origin-rightEdges
origin-top-left … origin-bottom-rightCorners
origin-[30%_70%]Arbitrary
Loading preview…

Origin matters most for menus and tooltips — a dropdown scaling from origin-top looks like it is unfolding from its trigger, while origin-center looks like it is inflating.

3D transforms#

v4 v4 added a full set of 3D transform utilities.

UtilityEffect
perspective-near … perspective-distantDepth of field on a parent
perspective-origin-*Vanishing point
transform-3dEnable transform-style: preserve-3d
rotate-x-45 rotate-y-30 rotate-z-12Axis rotation
translate-z-12Depth
scale-z-125Depth scale
backface-visible / backface-hiddenShow or hide the reverse face
Loading preview…

The parent needs perspective-* for any 3D rotation to look like depth rather than a flat squash.

Flip card#

Loading preview…

zoom-*#

v4.3 The zoom property scales an element and its layout box, unlike scale-* which only scales the rendering.

UtilityEffect
zoom-75 zoom-100 zoom-125Preset zoom levels
zoom-[1.1]Arbitrary
zoom-(--preview-zoom)From a variable
HTML
<div class="zoom-75">Everything inside is 75% size, and takes 75% of the space.</div>
scale-75zoom-75
Affects layoutNo — leaves a gapYes — reflows
Animatable cheaplyYesNo
Right forHover effects, animationPreview panes, density controls

Common patterns#

Centring absolutely#

HTML
<div class="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2">Centred</div>

translate-x-1/2 is relative to the element's own width, which is exactly what this pattern needs.

Press feedback#

HTML
<button class="rounded-md bg-indigo-600 px-4 py-2 text-white transition active:scale-95">Click</button>

Image zoom inside a fixed frame#

Loading preview…

overflow-hidden on the wrapper is what keeps the zoom inside the frame.

Chevron that rotates when open#

HTML
<svg class="size-4 transition-transform group-open:rotate-180">…</svg>
HTML
<div class="origin-top scale-95 opacity-0 transition duration-150 data-[open=true]:scale-100 data-[open=true]:opacity-100">
  …
</div>

Common mistakes#

  • Expecting a transform to move neighbours. Transforms do not affect layout; siblings stay put. Use margin or zoom-* if you need reflow.
  • 3D rotation with no perspective-* on the parent. It looks like a flat squash.
  • transform on a parent of a fixed child. The child becomes fixed to the transformed ancestor, not the viewport — see Position.
  • scale-* on text. It scales the rendered pixels, so text goes blurry. Change font-size instead.
  • Forgetting backface-hidden on a flip card. You see a mirrored copy of the front through the back.
  • Transform without transition. The change is instant.
  • hover:scale-110 on a card containing a hover-activated dropdown. The transform creates a containing block that traps the menu.