A chat bubble pops in with three bouncing dots, then stretches open and the message fades in where the dots were. The bubble grows with an animated clip-path, so nothing reflows.
Also known as: typing indicator to message, chat message animation css, messenger typing bubble.
See you at 7?
<div class="txt-chat-bubble-typing">
<span class="txt-chat-bubble-typing-avatar" aria-hidden="true">M</span>
<p class="txt-chat-bubble-typing-bubble">
<span class="txt-chat-bubble-typing-dots" aria-hidden="true"><i></i><i></i><i></i></span>
<span class="txt-chat-bubble-typing-msg">See you at 7?</span>
</p>
</div>.txt-chat-bubble-typing {
--c: var(--txt-color, #3b82f6);
font-size: var(--txt-size, 32px);
font-family: system-ui, sans-serif;
font-weight: 700;
line-height: 1.2;
display: inline-flex;
align-items: flex-end;
gap: 0.45em;
font-size: calc(var(--txt-size, 32px) * 0.75);
font-weight: 500;
line-height: 1.3;}
.txt-chat-bubble-typing-avatar {
display: grid;
place-items: center;
width: 1.7em;
height: 1.7em;
border-radius: 50%;
font-size: 0.85em;
font-weight: 700;
color: #fff;
background: var(--c);
}
.txt-chat-bubble-typing-bubble {
position: relative;
isolation: isolate;
display: grid;
margin: 0;
padding: 0.5em 0.85em;
transform-origin: 0 100%;
animation: txt-chat-bubble-typing-pop 0.35s cubic-bezier(0.3, 1.5, 0.5, 1) both;
}
/* the bubble fill starts just wide enough for the dots, then opens up */
.txt-chat-bubble-typing-bubble::before {
content: "";
position: absolute;
inset: 0;
z-index: -1;
border-radius: 1em 1em 1em 0.3em;
background: color-mix(in srgb, currentColor 10%, transparent);
clip-path: inset(0 calc(100% - 3.3em) 0 0 round 1em 1em 1em 0.3em);
animation: txt-chat-bubble-typing-open 0.45s cubic-bezier(0.2, 0.8, 0.2, 1) 1.55s forwards;
}
.txt-chat-bubble-typing-dots,
.txt-chat-bubble-typing-msg {
grid-area: 1 / 1;
}
.txt-chat-bubble-typing-dots {
display: flex;
align-items: center;
gap: 0.22em;
animation: txt-chat-bubble-typing-hide 0.15s linear 1.55s forwards;
}
.txt-chat-bubble-typing-dots i {
width: 0.4em;
height: 0.4em;
border-radius: 50%;
background: color-mix(in srgb, currentColor 45%, transparent);
animation: txt-chat-bubble-typing-bounce 0.9s ease-in-out infinite;
}
.txt-chat-bubble-typing-dots i:nth-child(2) { animation-delay: 0.15s; }
.txt-chat-bubble-typing-dots i:nth-child(3) { animation-delay: 0.3s; }
.txt-chat-bubble-typing-msg {
white-space: nowrap;
animation: txt-chat-bubble-typing-msg 0.35s ease-out 1.75s both;
}
@keyframes txt-chat-bubble-typing-pop {
from { opacity: 0; transform: scale(0.5); }
}
@keyframes txt-chat-bubble-typing-open {
to { clip-path: inset(0 0 0 0 round 1em 1em 1em 0.3em); }
}
@keyframes txt-chat-bubble-typing-hide {
to { opacity: 0; }
}
@keyframes txt-chat-bubble-typing-bounce {
0%, 60%, 100% { transform: translateY(0); opacity: 0.6; }
30% { transform: translateY(-0.2em); opacity: 1; }
}
@keyframes txt-chat-bubble-typing-msg {
from { opacity: 0; transform: translateY(0.3em); }
}
@media (prefers-reduced-motion: reduce) {
.txt-chat-bubble-typing, .txt-chat-bubble-typing *, .txt-chat-bubble-typing::before, .txt-chat-bubble-typing::after, .txt-chat-bubble-typing *::before, .txt-chat-bubble-typing *::after {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
}
}--txt-color on the element or a parent.
Currently previewing #3b82f6.--txt-size. Every other dimension is in
em, so the whole thing scales together. Currently previewing 40px.transition or animation
shorthand. Staggered delays are relative, so they keep their rhythm.