A chat bubble that swells from its tail and sets the three dots inside bouncing like a typing indicator. The dots are filled circles in the same SVG with staggered animation delays.
Also known as: message icon animation css, typing indicator icon, chat icon hover.
<button class="hfx-chat-icon-typing" aria-label="Open chat"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><g class="hfx-chat-icon-typing-bubble"><path d="M21 11.5a8.4 8.4 0 0 1-12.2 7.5L3 21l2-5.3A8.5 8.5 0 1 1 21 11.5Z"/><circle class="hfx-chat-icon-typing-dot" cx="8.5" cy="11.5" r="1.25" fill="currentColor" stroke="none"/><circle class="hfx-chat-icon-typing-dot" cx="12.5" cy="11.5" r="1.25" fill="currentColor" stroke="none"/><circle class="hfx-chat-icon-typing-dot" cx="16.5" cy="11.5" r="1.25" fill="currentColor" stroke="none"/></g></svg></button>
.hfx-chat-icon-typing {
--c: var(--hfx-color, #3b82f6);
font-size: var(--hfx-size, 16px);
position: relative;
display: grid;
place-items: center;
width: 3.5em;
height: 3.5em;
padding: 0;
border: 0;
border-radius: 50%;
cursor: pointer;
background: color-mix(in srgb, var(--c) 12%, transparent);
color: var(--c);
transition: background-color 0.25s ease;}
.hfx-chat-icon-typing svg {
width: 1.65em;
height: 1.65em;
overflow: visible;
}
.hfx-chat-icon-typing-bubble,
.hfx-chat-icon-typing-dot {
transform-box: view-box;
transform-origin: 12.5% 87.5%;
}
.hfx-chat-icon-typing-bubble {
transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.hfx-chat-icon-typing:is(:hover, :focus-visible) { background: color-mix(in srgb, var(--c) 20%, transparent); }
.hfx-chat-icon-typing:is(:hover, :focus-visible) .hfx-chat-icon-typing-bubble { transform: scale(1.08); }
.hfx-chat-icon-typing:is(:hover, :focus-visible) .hfx-chat-icon-typing-dot {
animation: hfx-chat-icon-typing-bob 1s ease-in-out infinite;
}
.hfx-chat-icon-typing:is(:hover, :focus-visible) .hfx-chat-icon-typing-dot:nth-of-type(2) { animation-delay: 0.15s; }
.hfx-chat-icon-typing:is(:hover, :focus-visible) .hfx-chat-icon-typing-dot:nth-of-type(3) { animation-delay: 0.3s; }
@keyframes hfx-chat-icon-typing-bob {
0%, 60%, 100% { transform: translateY(0); opacity: 0.45; }
30% { transform: translateY(-12%); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
.hfx-chat-icon-typing, .hfx-chat-icon-typing *, .hfx-chat-icon-typing::before, .hfx-chat-icon-typing::after, .hfx-chat-icon-typing *::before, .hfx-chat-icon-typing *::after {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
}
}--hfx-color on the element or a parent.
Currently previewing #3b82f6.--hfx-size. Every other dimension is in
em, so the whole thing scales together. Currently previewing 16px.transition or animation
shorthand. Staggered delays are relative, so they keep their rhythm.