02Bubble morph — three dots merging into one bubble's size
When the typing state ends, the combined width of the three dots interpolates toward a single bubble's width, and the message content takes over exactly when the interpolation finishes.
Best forA messenger app's live conversation screen, human-to-human chat (not a bot)
setPropertyrequestAnimationFrameprefers-reduced-motion

<main class="stage">
<section class="panel">
<div class="row">
<span class="avatar" aria-hidden="true"></span>
<div class="bubble" id="bubble" role="status" aria-live="polite">
<span class="dots" id="dots">
<span class="dot"></span><span class="dot"></span><span class="dot"></span>
</span>
<span class="msg" id="msg">Message received</span>
</div>
</div>
</section>
</main>@use "../../../../site/static/demo-tokens" as *;
@include stage($stage-yellow);
.panel { display: flex; flex-direction: column; align-items: center; gap: $sp-4; }
.row { display: flex; align-items: center; gap: $sp-3; }
.avatar { width: 32px; height: 32px; border-radius: $r-pill; background: $subject-ink; flex: none; }
// --w 는 점 3개의 합산 폭에서 메시지 폭까지 JS 가 매 프레임 재계산해 넣는 값(px, 단위 없이 저장)
.bubble {
position: relative;
height: 44px;
width: calc(var(--w, 56) * 1px);
border-radius: $r-card;
background: $subject-ink;
overflow: hidden;
}
.dots, .msg {
position: absolute;
inset: 0;
display: flex;
align-items: center;
justify-content: center;
gap: $sp-2;
}
.dot {
width: 8px;
height: 8px;
border-radius: 50%;
background: $subject-cream;
}
.msg {
color: $subject-cream;
font-size: 13px;
white-space: nowrap;
padding: 0 $sp-3;
opacity: 0;
}
@media (max-width: 340px) {
.bubble { height: 38px; }
.avatar { width: 26px; height: 26px; }
.msg { font-size: 12px; }
}
@media (prefers-reduced-motion: reduce) {
.dots, .msg { transition: none; }
}html, body {
margin: 0;
overflow: hidden;
}
.stage {
box-sizing: border-box;
min-height: 100vh;
display: grid;
place-items: center;
margin: 0;
background: #ffd23f;
font-family: -apple-system, "Segoe UI", "Noto Sans KR", sans-serif;
padding: clamp(8px, 4vw, 24px);
}
.panel {
display: flex;
flex-direction: column;
align-items: center;
gap: 16px;
}
.row {
display: flex;
align-items: center;
gap: 12px;
}
.avatar {
width: 32px;
height: 32px;
border-radius: 999px;
background: #17141a;
flex: none;
}
.bubble {
position: relative;
height: 44px;
width: calc(var(--w, 56) * 1px);
border-radius: 16px;
background: #17141a;
overflow: hidden;
}
.dots, .msg {
position: absolute;
inset: 0;
display: flex;
align-items: center;
justify-content: center;
gap: 8px;
}
.dot {
width: 8px;
height: 8px;
border-radius: 50%;
background: #fff7e6;
}
.msg {
color: #fff7e6;
font-size: 13px;
white-space: nowrap;
padding: 0 12px;
opacity: 0;
}
@media (max-width: 340px) {
.bubble {
height: 38px;
}
.avatar {
width: 26px;
height: 26px;
}
.msg {
font-size: 12px;
}
}
@media (prefers-reduced-motion: reduce) {
.dots, .msg {
transition: none;
}
}// 말풍선 모핑 — 점 세 개의 합산 너비 값을 말풍선 하나의 너비 값으로 보간한다.
// 계산 겹: 경과 비율 → 너비 값(px) 재계산 → CSS 커스텀 프로퍼티(--w)에 반영. 자동 재생만, 실사용자 리스너 없음.
(function () {
var bubble = document.getElementById('bubble');
var dots = document.getElementById('dots');
var msg = document.getElementById('msg');
if (!bubble || !dots || !msg) return;
var DOT_W = 56;
var MSG_W = 168;
var CYCLE_MS = 2000;
var MORPH_START = 0.10 * CYCLE_MS;
var MORPH_MS = 640;
var REVERT_AT = 0.62 * CYCLE_MS;
function easeOut(p) { return 1 - Math.pow(1 - p, 3); }
function apply(t) {
var inMorph = t >= MORPH_START && t < REVERT_AT;
var p = Math.min(Math.max((t - MORPH_START) / MORPH_MS, 0), 1);
var eased = easeOut(p);
var w = inMorph ? DOT_W + (MSG_W - DOT_W) * eased : DOT_W;
bubble.style.setProperty('--w', w.toFixed(1));
var done = inMorph && p >= 1;
dots.style.opacity = done ? '0' : '1';
msg.style.opacity = done ? '1' : '0';
}
apply(0);
var reduce = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
if (reduce) { bubble.style.setProperty('--w', DOT_W); return; }
var start = null;
function loop(ts) {
if (start === null) start = ts;
var t = (ts - start) % CYCLE_MS;
apply(t);
requestAnimationFrame(loop);
}
requestAnimationFrame(loop);
})();import { useEffect, useRef } from "react";
import styles from "./TypingBubbleMorphIn.module.scss";
// 말풍선 모핑 — 점 세 개의 합산 너비 값을 말풍선 하나의 너비 값으로 보간한다.
// 계산 겹: 경과 비율 → 너비 값(px) 재계산 → CSS 커스텀 프로퍼티(--w)에 반영. 자동 재생만, 실사용자 리스너 없음.
const DOT_W = 56;
const MSG_W = 168;
const CYCLE_MS = 2000;
const MORPH_START = 0.10 * CYCLE_MS;
const MORPH_MS = 640;
const REVERT_AT = 0.62 * CYCLE_MS;
function easeOut(p: number) {
return 1 - Math.pow(1 - p, 3);
}
export default function TypingBubbleMorphIn() {
const bubbleRef = useRef<HTMLDivElement>(null);
const dotsRef = useRef<HTMLSpanElement>(null);
const msgRef = useRef<HTMLSpanElement>(null);
useEffect(() => {
const bubble = bubbleRef.current;
const dots = dotsRef.current;
const msg = msgRef.current;
if (!bubble || !dots || !msg) return;
function apply(t: number) {
const inMorph = t >= MORPH_START && t < REVERT_AT;
const p = Math.min(Math.max((t - MORPH_START) / MORPH_MS, 0), 1);
const eased = easeOut(p);
const w = inMorph ? DOT_W + (MSG_W - DOT_W) * eased : DOT_W;
bubble!.style.setProperty("--w", w.toFixed(1));
const done = inMorph && p >= 1;
dots!.style.opacity = done ? "0" : "1";
msg!.style.opacity = done ? "1" : "0";
}
apply(0);
const reduce = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
if (reduce) {
bubble.style.setProperty("--w", String(DOT_W));
return;
}
let start: number | null = null;
let raf = 0;
function loop(ts: number) {
if (start === null) start = ts;
const t = (ts - start) % CYCLE_MS;
apply(t);
raf = requestAnimationFrame(loop);
}
raf = requestAnimationFrame(loop);
return () => cancelAnimationFrame(raf);
}, []);
return (
<div className={styles.stage}>
<section className={styles.panel}>
<div className={styles.row}>
<span className={styles.avatar} aria-hidden="true" />
<div ref={bubbleRef} className={styles.bubble} role="status" aria-live="polite">
<span ref={dotsRef} className={styles.dots}>
<span className={styles.dot} />
<span className={styles.dot} />
<span className={styles.dot} />
</span>
<span ref={msgRef} className={styles.msg}>메시지 도착</span>
</div>
</div>
</section>
</div>
);
}02 Bubble morph — three dots merging into one bubble's size — Measured area 4.594% · moving frames 13/23Original by GODRICH · SCSS and React ship in the zip · 9 Typing Indicator CSS Patterns (Chat UI)
The post this demo lives in
9 Typing Indicator CSS Patterns (Chat UI)One of nine typing indicators slows its avatar pulse as typing runs longer, one redraws a group name tag from remaining See all demos in this post
If you like this effect - similar demos
Loaders04 Multi-file stagger — progress rows that queue in one by oneFile Upload Progress Bar Loader: 9 UI Demos
Loaders04 Load-more button morph — a button recomputing its width from the remaining item countInfinite Scroll Loading: 9 Essential UI Patterns
Loaders05 Icon progress ring — an indicator whose circular progress value fills with the pulled distance and morphs into a checkmark once completePull to Refresh CSS: 9 Loading Patterns