π Introduction
The transition-delay property controls **when** a transition begins. Instead of starting immediately, you can delay animations by a specified time (seconds or milliseconds). This is useful for sequencing animations, staggering UI elements, hover delays, and smooth visual storytelling. π¨β¨
π― What Does transition-delay Do?
- Sets a wait time before the transition starts
- Used in combination with
transition-propertyandtransition-duration - Useful for staggered animations & hover effects
- Accepts seconds (s) or milliseconds (ms)
β¨ Syntax
Syntax
selector {
transition-delay: <time>;
}Examples of valid time values:0.5s, 2s, 150ms, 700ms
Note
π§© Single & Multiple Delays
1. Single Property Delay
Single Delay
.box {
transition-property: opacity;
transition-duration: 1s;
transition-delay: 0.3s;
}2. Multiple Delays (When Using Multiple Properties)
Each delay corresponds to each transition property in the same order.
Multiple Delay
.box {
transition-property: opacity, transform;
transition-duration: 1s, 0.5s;
transition-delay: 0s, 0.2s;
}π₯ Practical Examples
1. Delayed Hover Effect
Delayed Hover
.button {
transition: background-color 0.5s ease 0.4s;
}
.button:hover {
background-color: #4f46e5;
}2. Staggered Animation on List Items
Staggered Items
.item {
opacity: 0;
transform: translateY(20px);
transition: opacity 0.6s ease, transform 0.6s ease;
}
.item:nth-child(1) { transition-delay: 0s; }
.item:nth-child(2) { transition-delay: 0.2s; }
.item:nth-child(3) { transition-delay: 0.4s; }
.item:nth-child(4) { transition-delay: 0.6s; }
.container.show .item {
opacity: 1;
transform: translateY(0);
}3. Dropdown Menu with Delay
Dropdown Delay
.dropdown-menu {
opacity: 0;
transition: opacity 0.3s ease 0.15s;
}
.dropdown:hover .dropdown-menu {
opacity: 1;
}4. Delay Only the Exit Animation
Use negative delay values to start transitions mid-way.
Negative Delay
.fade-out {
transition: opacity 1s ease -0.5s;
opacity: 0;
}Note
π Understanding Full Transition Syntax
Full Syntax
transition: <property> <duration> <timing-function> <delay>;| Value | Description |
|---|---|
| transition-property | Which property to animate |
| transition-duration | How long the animation takes |
| transition-timing-function | Speed curve (ease, linear, etc.) |
| transition-delay | When the animation should start |
π§ Tips & Best Practices
- Use small delays (100β300ms) to improve UX
- Great for staggered or cascading animations
- Be cautious: long delays may feel slow or unresponsive
- Use negative delays for quick exit animations
- Use
transitionshorthand for cleaner code
π Conclusion
The transition-delay property lets you control precisely **when** animations begin, making your UI interactions feel smoother, intentional, and more expressive. Combine it with duration, timing-function, and property to create polished and engaging visual transitions. π