About this snippet

Design a beautiful AI chat bubble interface. We included user messages and an animated typing indicator, so you can build a seamless conversational experience easily.

Size
2.5 KB
Uses
HTML, CSS
Loads
Nothing external
Views
360
<div class="chat-container">
  
  <div class="message-row user-row">
    <div class="bubble user-bubble">
      Can you summarize the meeting notes from today?
    </div>
  </div>
  
  <div class="message-row ai-row">
    <div class="avatar ai-avatar">AI</div>
    <div class="bubble ai-bubble">
      Certainly! Here are the key takeaways from the meeting...
    </div>
  </div>
  
  <div class="message-row user-row">
    <div class="bubble user-bubble">
      That is perfect, thank you!
    </div>
  </div>
  
  <div class="message-row ai-row">
    <div class="avatar ai-avatar">AI</div>
    <div class="bubble ai-bubble typing-bubble">
      <div class="dot dot-1"></div>
      <div class="dot dot-2"></div>
      <div class="dot dot-3"></div>
    </div>
  </div>
  
</div>
*, *::before, *::after {
  box-sizing: border-box;
}

body {
  font-family: system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
  margin: 0;
  background: #f1f5f9;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 20px;
}

.chat-container {
  width: 100%;
  max-width: 400px;
  background: #ffffff;
  border-radius: 24px;
  padding: 24px;
  box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.message-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  width: 100%;
}

.user-row {
  justify-content: flex-end;
}

.ai-row {
  justify-content: flex-start;
}

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: #ffffff;
  flex-shrink: 0;
}

.ai-avatar {
  background: linear-gradient(135deg, #8b5cf6, #3b82f6);
}

.bubble {
  max-width: 75%;
  padding: 12px 16px;
  font-size: 0.95rem;
  line-height: 1.5;
  border-radius: 18px;
}

.user-bubble {
  background: #3b82f6;
  color: #ffffff;
  border-bottom-right-radius: 4px;
}

.ai-bubble {
  background: #f1f5f9;
  color: #1e293b;
  border-bottom-left-radius: 4px;
}

/* Typing Indicator Animation */
.typing-bubble {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 16px 20px;
}

.dot {
  width: 6px;
  height: 6px;
  background: #94a3b8;
  border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out both;
}

.dot-1 { animation-delay: -0.32s; }
.dot-2 { animation-delay: -0.16s; }
.dot-3 { animation-delay: 0s; }

@keyframes bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}
Esc
↑↓ moveEnter select

Start from a template

Open an .html file, or HTML, CSS, JS, Markdown, Less or TypeScript files. You can also drop them here. Styles and scripts go into their panes.

Share

Source

Keyboard shortcuts

Save