AI Snippet

Copy. Paste. Ship.

Home › Code Snippets › AI › Typing Indicator

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.

Standard
Compact
📝

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 durationSpeed of bounce1.4s
Dot sizeVisual weight8px
Accent colorPeak color#3b82f6
translateYLift height-6px

🎯 Use Cases

⚠️ Common Mistakes

🎯 What's Next?

← AI Hub