Transforms let you change how an element looks by moving, turning, or resizing it without changing the page layout.
Transform (scale, rotate, translate) in Tailwind
Start learning this pattern below
Jump into concepts and practice - no test required
class="transform scale-110 rotate-45 translate-x-4 translate-y-2"transform class to enable transformations on an element.<div class="transform scale-125">Text bigger</div><div class="transform rotate-90">Rotated text</div><div class="transform translate-x-6 translate-y-3">Moved text</div><div class="transform scale-90 rotate-12 translate-x-2">Combined transform</div>This page shows three boxes: a button that grows bigger when hovered, a box rotated 45 degrees, and a box moved right and down. The transform class enables the changes, and scale, rotate, translate classes adjust the look.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <title>Tailwind Transform Example</title> <script src="https://cdn.tailwindcss.com"></script> </head> <body class="flex flex-col items-center justify-center min-h-screen gap-6 bg-gray-50"> <button class="transform scale-110 bg-blue-500 text-white px-6 py-3 rounded hover:scale-125 transition-transform"> Hover me to grow </button> <div class="transform rotate-45 bg-green-300 p-4 rounded"> Rotated box </div> <div class="transform translate-x-8 translate-y-4 bg-red-300 p-4 rounded"> Moved box </div> </body> </html>
Always add the transform class before scale, rotate, or translate classes to activate transformations.
Use transition-transform for smooth animation effects when transforms change.
Transforms do not affect the space the element takes on the page, so other elements stay in place.
Transforms let you move, rotate, or resize elements visually without changing layout.
Tailwind uses transform plus scale, rotate, and translate classes to apply these effects.
Combine transforms and add transitions for smooth interactive effects.
Practice
scale-110 do to an element?Solution
Step 1: Understand the scale utility
Thescale-110class in Tailwind increases the size of the element by 110%, which means 10% larger than normal.Step 2: Differentiate from other transforms
Rotation and translation use different classes likerotate-andtranslate-. Transparency uses opacity classes, not scale.Final Answer:
It makes the element 10% larger than its original size. -> Option CQuick Check:
scale-110 means 110% size = 10% larger [OK]
- Confusing scale with rotate or translate
- Thinking scale changes transparency
- Assuming scale-110 means 110 pixels
Solution
Step 1: Identify rotation classes
Tailwind usesrotate-followed by degrees to rotate elements.rotate-45means rotate 45 degrees clockwise.Step 2: Exclude other transform types
scale-changes size,translate-moves position, androtate-90rotates 90 degrees, not 45.Final Answer:
rotate-45 -> Option AQuick Check:
rotate-45 means 45 degrees rotation [OK]
- Using scale or translate classes for rotation
- Choosing wrong rotation degree
- Confusing clockwise and counterclockwise directions
<div class="transform translate-x-4 rotate-90 scale-50 bg-blue-500 w-20 h-20">Box</div>
Solution
Step 1: Decode each transform class
translate-x-4moves the element right by 1rem (4 * 0.25rem),rotate-90rotates it 90 degrees clockwise, andscale-50scales it to 50% size (half).Step 2: Combine visual effects
The box will appear smaller (half size), rotated on its center by 90 degrees, and shifted right by 1rem. The background and size classes set color and base size.Final Answer:
A blue box half its size, rotated 90 degrees, moved right by 1rem -> Option DQuick Check:
translate-x-4 = 1rem right, rotate-90 = 90°, scale-50 = half size [OK]
- Misreading translate-x-4 as 4rem
- Confusing rotate-90 with rotate-45
- Assuming scale-50 means double size
<div class="transform scale-150 rotate-360 translate-y-6px">Content</div>
Solution
Step 1: Check translate-y syntax
Tailwind translate classes use predefined spacing scale liketranslate-y-6, not custom units like6px. Sotranslate-y-6pxis invalid.Step 2: Verify rotate and scale values
rotate-360is valid (full rotation), andscale-150is valid (150% size). Thetransformclass is present.Final Answer:
translate-y-6px is invalid; Tailwind uses spacing scale, not px units -> Option AQuick Check:
Tailwind translate uses scale numbers, not px [OK]
- Using px units in translate classes
- Thinking rotate-360 is invalid
- Assuming scale-150 is out of range
Solution
Step 1: Use hover prefix for interactive effects
To apply scale and rotate only on hover, usehover:scale-125andhover:rotate-15. The basetransformclass enables transforms.Step 2: Add smooth transition
Includetransition duration-300for smooth animation over 300ms. Other options either miss hover prefixes or use wrong values.Final Answer:
transform hover:scale-125 hover:rotate-15 transition duration-300 -> Option BQuick Check:
Hover scale 125 + rotate 15 + transition = transform hover:scale-125 hover:rotate-15 transition duration-300 [OK]
- Missing hover: prefix on scale or rotate
- Using wrong scale or rotate values
- Not including transform class
