Transitions & Animations
- Understand how to implement smooth transitions and engaging UI animations.
Until now, we learned:
States (hover, focus, active, etc.)
How UI reacts to user actions
Now we move to:
How those reactions visually happen over time
This lesson gives a big-picture understanding of:
Transitions
Animations
Their purpose
When to use which
Why Transitions & Animations Matter
Modern users expect UI to:
Respond smoothly
Feel natural
Communicate cause & effect
Guide attention
Without motion:
UI feels rigid
Feedback feels abrupt
Experience feels outdated
it’s communication.Overview of Transitions & Animations
What Are Transitions ?
A transition controls the smooth change between two states.
In simple words:
Transition animates a property when its value changes.
Example:
Button color changes on hover
Input border changes on focus
Transitions are:
State-driven
Short-lived
Triggered by interaction
What Are Animations ?
An animation controls movement that:
Can run automatically
Can loop
Can have multiple steps (keyframes)
In simple words:
Animation defines how an element behaves over time, even without user action.
Examples:
Loading spinner
Skeleton loader
Attention pulse
Entrance animation
Transition vs Animation
Transition Animation Triggered by state Runs independently Two states Multiple steps Simple Complex User interaction based Time based Best for hover/focus Best for loaders, effects Most UI interactions use transitions
Animations are used selectivelyHow They Work Together
In real UI:
Transitions handle micro-interactions
Animations handle continuous or scripted motion
A professional UI uses both - carefully.
When NOT to Use Motion
Avoid motion when:
It delays user action
It distracts from content
It causes confusion
It triggers motion sickness
Good motion is felt, not noticed.
Transition Properties
What Are Transition Properties ?
Transition properties define:
What changes, how long it takes, and how it moves
They control the behavior of transitions.
There are four core transition properties.
transition-property
Defines which CSS property should animate.
Examples:
color
background-color
opacity
transform
border-color
CSS Concept
transition-property: background-color;
Tailwind Equivalent (High-Level)
<div class="transition-colors"></div>
This tells the browser:
Animate color-related changes only
transition-duration
Defines how long the transition takes.
Examples:
0.1s → very fast
0.2s → natural
0.3s → smooth
0.5s+ → slow (use carefully)
CSS Concept
transition-duration: 0.2s;
Transition Property & Duration (CSS vs Tailwind)
Shows how to control what animates and how long it takes using CSS and Tailwind.
/* CSS Concept */
transition-property: background-color; /* what to animate */
transition-duration: 0.2s; /* how long */
/* Tailwind Equivalent */
<div class="transition-colors"></div> <!-- animate only color-related properties -->
<button class="transition duration-200 hover:bg-blue-600">
Hover me
</button> <!-- 200ms smooth transition -->
Duration controls responsiveness feel.
transition-timing-function
Defines how the motion progresses over time.
Common easing types:
linear → constant speed
ease-in → slow start
ease-out → slow end
ease-in-out → smooth both sides
CSS Concept
transition-timing-function: ease-out;
Tailwind Example
<div class="transition duration-300 ease-out hover:scale-105"></div>
Easing controls emotion of motion.
transition-delay
Defines how long to wait before starting the transition.
CSS Concept
transition-delay: 0.1s;
Transition Delay Utility
Shows how to add delay before animation starts using Tailwind.
/* CSS Concept */
transition-delay: 0.1s; /* wait before animation */
/* Tailwind Example */
<div class="transition delay-150 hover:opacity-100"></div>
Delay should be:
Rare
Intentional
Short
Combined Transition Properties
Shows how multiple transition properties work together in CSS and Tailwind.
/* CSS Concept */
transition:
background-color 0.2s ease-out 0s; /* property + duration + easing + delay */
/* Tailwind Combined */
<button
class="bg-blue-500
hover:bg-blue-600
transition-colors /* property */
duration-200 /* duration */
ease-out" /* easing */
>
Submit
</button>
This creates:
Smooth
Fast
Natural interaction
What Should Be Transitioned
Good properties:
color
opacity
transform
box-shadow
Avoid:
width / height
top / left (layout shift)
large layout properties
Input Focus Transition Pattern
Shows how input border smoothly changes on focus using transitions.
/* smooth focus transition for input */
<input
class="border border-gray-300
focus:border-blue-500 /* change on focus */
transition-colors /* animate color */
duration-200" /* speed */
/>
Result:
Focus feels responsive
User gets instant feedback
UI feels polished
Common Mistakes
Forgetting to add transition utility
Using very long durations
Animating too many properties
Overusing delay
Adding motion everywhere