Snippet
AI Typing Indicator
Three-dot bouncing animation signaling the AI is thinking or typing.
Last updated: October 2026
What this snippet does: A three-dot animated indicator that shows while an AI is generating a response. The middle dot lifts higher and turns blue, giving a natural rhythm. Pure CSS animation — no JS needed.
🎬 Live Demo
Standard and compact variants.
📝
How It Works
Three dots bounce in sequence using CSS keyframes. Each dot has a staggered animation-delay. The middle dot changes color to blue at the peak of its bounce.
1
HTML
<div class="typing-indicator">
<span class="dot"></span>
<span class="dot"></span>
<span class="dot"></span>
</div>
2
CSS
.typing-indicator {
display: inline-flex; align-items: center; gap: 5px;
padding: 0.75rem 1rem;
background: #1e293b;
border-radius: 1rem 1rem 1rem 0.25rem;
}
.typing-indicator .dot {
width: 8px; height: 8px; border-radius: 50%;
background: #64748b;
animation: typing-bounce 1.4s infinite ease-in-out;
}
.typing-indicator .dot:nth-child(1) { animation-delay: 0s; }
.typing-indicator .dot:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator .dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing-bounce {
0%, 60%, 100% { transform: translateY(0); background: #64748b; }
30% { transform: translateY(-6px); background: #3b82f6; }
}
3
JavaScript — Show/Hide Around API
async function askAI(prompt) {
appendMessage(prompt, 'user');
const indicator = document.createElement('div');
indicator.className = 'typing-indicator';
indicator.innerHTML = '<span class="dot"></span><span class="dot"></span><span class="dot"></span>';
appendToChat(indicator);
const res = await fetch('/api/chat', { /* ... */ });
const data = await res.json();
indicator.remove();
appendMessage(data.reply, 'bot');
}
🎨 Customization
| Property | Effect | Default |
|---|---|---|
| Animation duration | Speed of bounce | 1.4s |
| Dot size | Visual weight | 8px |
| Accent color | Peak color | #3b82f6 |
| translateY | Lift height | -6px |
🎯 Use Cases
- AI chat — Showing response is being generated
- Customer support — Agent is looking into it
- Comment threads — Someone is typing a reply
- Loading states — Generic "working on it" indicator
⚠️ Common Mistakes
- Not respecting prefers-reduced-motion. Add a media query to disable animation.
- Leaving the indicator visible. Always remove it when the response arrives or errors.
- Using too much delay. 1.4s cycle is pleasant; longer feels broken.
- Forgetting the container styling. Dots floating in space look odd — wrap in a bubble.