--- name: tailwindcss-transforms description: "Transform & Animation utilities Tailwind CSS v4.1. Transform (scale-*, rotate-*, translate-*, skew-*, transform-origin), Transition (transition-*, duration-*, ease-*, delay-*), Animation (animate-*, @keyframes)." user-invocable: false --- # Tailwind CSS Transforms & Animations v4.1 Complete reference for Transform, Transition, and Animation utilities in Tailwind CSS v4.1. ## Transform Utilities ### Scale Transform an element by scaling (resizing) it. ```html
50%
100%
125%
150%
Scale X only
Scale Y only
``` **Responsive**: `sm:scale-125`, `md:scale-150`, `lg:scale-100` **States**: `hover:scale-110`, `focus:scale-105`, `group-hover:scale-125` ### Rotate Rotate an element by an angle. ```html
45°
90°
180°
-45°
``` **Responsive**: `sm:rotate-90`, `md:rotate-180`, `lg:rotate-0` **States**: `hover:rotate-45`, `focus:rotate-90` ### Translate Move an element along X and Y axes. ```html
No translation
X direction
Y direction
Both axes
Negative X
Negative Y
``` **Responsive**: `sm:translate-x-4`, `md:translate-y-8` **States**: `hover:translate-y-2`, `focus:translate-x-1` ### Skew Skew an element along X and Y axes. ```html
Skew X
Skew Y
Both skew
Negative skew
``` **Responsive**: `sm:skew-x-6`, `md:skew-y-3` **States**: `hover:skew-x-2`, `group-hover:skew-y-4` ### Transform Origin Set the origin point for transform operations. ```html
Default center
Top
Bottom
Left
Right
Top-left
Top-right
Bottom-left
Bottom-right
``` **Responsive**: `sm:origin-top`, `md:origin-bottom-right` **States**: `hover:origin-left`, `focus:origin-center` ## Transition Utilities ### Transition Property Enable transitions on specific properties. ```html
All properties
No transitions
All properties
Color changes
Opacity changes
Transform changes
Shadow changes
``` **Responsive**: `sm:transition-colors`, `md:transition-transform` **States**: `hover:transition-all`, `focus:transition-opacity` ### Duration Set the duration of a transition or animation. ```html
75ms
100ms
150ms
200ms
300ms
500ms
700ms
1000ms
``` **Responsive**: `sm:duration-200`, `md:duration-500` **Common**: `hover:duration-300`, `focus:duration-200` ### Timing Function (Easing) Control the acceleration curve of a transition or animation. ```html
Linear
Ease in (slow start)
Ease out (slow end)
Ease in-out
``` **Responsive**: `sm:ease-in`, `md:ease-out` **States**: `hover:ease-linear`, `focus:ease-in-out` ### Delay Add a delay before a transition or animation starts. ```html
0ms
75ms
100ms
150ms
200ms
300ms
500ms
700ms
1000ms
``` **Responsive**: `sm:delay-150`, `md:delay-300` **Staggering**: Sequential delays for animations ## Animation Utilities ### Animate Apply built-in animations or custom @keyframes. ```html
No animation
Rotating spinner
Pulsing beacon
Fading pulse
Bouncing motion
Wiggle motion
Wave motion
``` **Responsive**: `sm:animate-spin`, `md:animate-bounce` **Responsive Disable**: `lg:animate-none` ### Custom Keyframes Define custom animations with @keyframes. ```css /* In your CSS or Tailwind config */ @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } } @keyframes slideInUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } } @keyframes slideInDown { from { transform: translateY(-20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } } @keyframes slideInLeft { from { transform: translateX(-20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } } @keyframes slideInRight { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } } @keyframes scaleIn { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1; } } ``` ## Combining Transforms, Transitions & Animations ### Example 1: Hover Scale with Transition ```html ``` ### Example 2: Spinning Loader with Animation ```html
``` ### Example 3: Staggered Animation with Delay ```html
Item 1
Item 2
Item 3
``` ### Example 4: Complex Transform Combination ```html
Complex transform
``` ### Example 5: Origin-based Scaling ```html
Scale from bottom
``` ## Best Practices 1. **Use Duration with Transition**: Always pair `transition-*` with `duration-*` 2. **Add Easing for Smoothness**: Use `ease-out` or `ease-in-out` for natural motion 3. **Mobile First**: Apply base transforms, use responsive variants for larger screens 4. **Performance**: Use `transform` and `opacity` for best performance 5. **Accessibility**: Respect `prefers-reduced-motion` for animations 6. **Combine Operators**: Use state variants like `hover:`, `focus:`, `group-hover:` ## Performance Tips - Use `transform` instead of `left`/`top` for positioning - Use `opacity` instead of `visibility` for fade effects - Prefer `scale` over `width`/`height` changes - Apply animations only when necessary - Use `animation-delay` for staggered effects - Consider `will-change` for heavy animations ## Accessibility Considerations ```css /* Respect user preferences */ @media (prefers-reduced-motion: reduce) { * { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; } } ``` ## Resources - [Tailwind CSS Transforms Docs](https://tailwindcss.com/docs/transform) - [Tailwind CSS Transitions Docs](https://tailwindcss.com/docs/transition-property) - [Tailwind CSS Animation Docs](https://tailwindcss.com/docs/animation) - [MDN CSS Transforms](https://developer.mozilla.org/en-US/docs/Web/CSS/transform) - [MDN CSS Animations](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Animations)