TExcelTAD
Home › Tailwind CSS › Tailwind Transforms

Tailwind Transforms

Transforms move, rotate, scale and skew elements without affecting the layout around them. They are perfect for hover effects, icons and playful details.

In v4 each transform utility sets its own CSS property (scale, rotate, translate), so you no longer need the transform class that v3 required — just add rotate-45.

Scale

Class Effect
scale-50 / scale-75 / scale-100 / scale-110 / scale-150 uniform scaling in %
scale-x-125 / scale-y-50 one axis
-scale-x-100 mirror horizontally

Rotate

Class Effect
rotate-6 / rotate-45 / rotate-90 / rotate-180 degrees clockwise
-rotate-12 anticlockwise

Translate

Class Effect
translate-x-4 / -translate-y-2 move by the spacing scale
translate-x-1/2 / -translate-y-full move by a fraction of the element's own size
translate-x-px move by 1px

Skew and origin

Class Effect
skew-x-12 / -skew-y-6 slant
origin-center (default) / origin-top-left / origin-bottom the point transforms happen around
html · try it yourself
<!DOCTYPE html>
<html>
<head>
  <script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4.1.11"></script>
</head>
<body class="grid grid-cols-4 gap-6 p-8 text-center text-xs text-white">
  <div class="rounded-lg bg-sky-500 p-4 opacity-40">original</div>
  <div class="scale-75 rounded-lg bg-sky-500 p-4">scale-75</div>
  <div class="rotate-12 rounded-lg bg-sky-500 p-4">rotate-12</div>
  <div class="translate-x-4 -translate-y-2 rounded-lg bg-sky-500 p-4">translate</div>
  <div class="skew-x-12 rounded-lg bg-sky-500 p-4">skew-x-12</div>
  <div class="origin-top-left rotate-12 rounded-lg bg-sky-500 p-4">origin-top-left</div>
  <div class="-scale-x-100 rounded-lg bg-sky-500 p-4">mirrored</div>
  <div class="scale-110 -rotate-6 rounded-lg bg-sky-500 p-4">combined</div>
</body>
</html>

Notice how the transformed boxes overlap their neighbours' space without pushing them — the layout is calculated as if the transform weren't there.

Interactive transforms

Transforms really shine combined with hover:/group-hover: and a transition:

html · try it yourself
<!DOCTYPE html>
<html>
<head>
  <script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4.1.11"></script>
</head>
<body class="flex flex-wrap items-center gap-8 p-8">
  <div class="flex size-24 items-center justify-center rounded-2xl bg-rose-400 text-4xl transition duration-300 hover:scale-125 hover:rotate-6">🍓</div>
  <a href="#" class="group flex items-center gap-2 rounded-full bg-gray-900 px-5 py-2 text-white">
    Next lesson
    <span class="transition-transform group-hover:translate-x-1.5">→</span>
  </a>
  <button class="rounded-lg bg-emerald-500 px-5 py-2 font-semibold text-white transition active:scale-90">Press me</button>
</body>
</html>

Centring with translate

A classic trick for centring an absolutely positioned element of unknown size: move its top-left corner to the middle, then pull it back by half its own size.

html · try it yourself
<!DOCTYPE html>
<html>
<head>
  <script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4.1.11"></script>
</head>
<body class="p-4">
  <div class="relative h-56 rounded-xl bg-linear-to-br from-indigo-500 to-purple-600">
    <div class="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 rounded-lg bg-white px-4 py-2 font-semibold shadow-lg">
      I'm centred 🎯
    </div>
  </div>
</body>
</html>

3D transforms (new in v4)

v4 adds 3D utilities: rotate-x-*, rotate-y-*, translate-z-*, perspective-* (on the parent), transform-3d (keep children in 3D space) and backface-hidden.

html · try it yourself
<!DOCTYPE html>
<html>
<head>
  <script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4.1.11"></script>
</head>
<body class="flex gap-10 p-10 perspective-distant">
  <div class="flex size-28 items-center justify-center rounded-xl bg-amber-400 font-bold rotate-x-50 rotate-z-20">rotate-x</div>
  <div class="flex size-28 items-center justify-center rounded-xl bg-teal-400 font-bold rotate-y-45">rotate-y</div>
  <div class="flex size-28 items-center justify-center rounded-xl bg-pink-400 font-bold transition duration-700 hover:rotate-y-180">hover me</div>
</body>
</html>

Tip: Animate scale, rotate, translate and opacity rather than width, top or margin — browsers can animate transforms on the GPU, which keeps motion smooth.

Test yourself

In Tailwind v4, what do you need to add along with rotate-45?

  1. transform
  2. transform-gpu
  3. Nothing — rotate-45 works on its own
  4. origin-center

What does -translate-y-1/2 do?

  1. Moves the element up by half the parent's height
  2. Moves the element up by half its own height
  3. Scales it to 50% height
  4. Moves it down 0.5rem

Why do transforms not push neighbouring elements around?

  1. They only work on absolute elements
  2. Transforms are applied after layout, so the original space is kept
  3. Tailwind adds negative margins
  4. Neighbours get z-index