How it works
Pure CSS, animating only transform and opacity. The three dots share one set of keyframes and are staggered with animation-delay. Every size derives from one variable, the dot diameter; the bubble is 4× + 12px high (40px at md, level with a one-line message). The root has a fixed size and the bounce takes no layout space, so swapping the dots for a real reply never moves the first line. A round takes 1.2s by default. The bubble colour comes from --ds-typing-bubble (default --ds-surface-2) so it can match the message bubbles around it.
Use it for
- Chat or support messaging, while the other side is typing: it holds the place of the next message.
- An AI conversation, between sending and the first word coming back.
- Very short waits inside buttons or inputs (bubble={false} with pulse).
Look elsewhere when
- Waits where progress or steps are known: use a progress ring or a step checklist.
- Whole blocks of content loading: use a skeleton; dots cannot fill an area.
- Waits longer than ten seconds or so: three dots alone make people suspect it is stuck; add text or a timeout message.
Usage
import { TypingDots } from './TypingDots.jsx'
export function MessageList({ messages, peerTyping }) {
return (
// role="log": new messages and the typing state are announced
<div role="log" aria-label="Chat with support">
{messages.map((m) => (
<p key={m.id}>{m.text}</p>
))}
{peerTyping && <TypingDots label="Support is typing" />}
</div>
)
}
// Without a bubble, inside your own bubble or button:
// <TypingDots bubble={false} variant="pulse" size="sm" label="AI is thinking" />Props
| Prop | Type | Default | What it does |
|---|---|---|---|
variant | 'bounce' | 'pulse' | 'wave' | 'bounce' | Animation style: dots jump in turn, brighten and grow in place, or rise and fall as a continuous wave. |
size | 'sm' | 'md' | 'lg' | number | 'md' | Dot diameter 5 / 7 / 9px, or a pixel value. Spacing and bubble scale with it (md bubble is 40px tall). |
bubble | boolean | true | Draws the chat bubble behind the dots (a rounded block with a small bottom-left corner). Off leaves only the dots. Set --ds-typing-bubble (and --ds-typing-bubble-shadow) to match your message bubbles, for example --ds-surface on a --ds-surface-2 chat panel. |
label | string | 'Typing' | Screen-reader text, such as "Support is typing" or "AI is thinking". |
duration | number | 1200 | Length of one round in ms. Below 900 is not recommended. |
...rest | HTMLAttributes<HTMLSpanElement> | — | Other attributes go to the root, such as className and style. The dots follow the root's color. |
Accessibility
- The root has role="status" and an aria-label (default "Typing"); the three dots are aria-hidden.
- A visually hidden copy of the same text sits inside: live regions announce content changes, and many screen readers stay silent with only an aria-label.
- The dots usually mount and unmount with messages: place them inside a permanent role="log" or aria-live container, as in the usage example.
- With reduced motion the dots stay still and the group fades slowly in and out at 1.6s, so it still reads as in progress; the entrance scale is removed too.
- Display only and not focusable, so it never interrupts keyboard use.
Motion
One round is 1200ms, looping. Bounce rises 20% with ease-out, falls 18% with ease-in, then squashes and recovers; pulse scales 0.72 to 1.1 with fading; wave rises and falls continuously. Entrance 240ms ease-out from 0.86 scale.
Add it to your project
Copy the prompt into Codex or Claude Code. The agent reads the published source, shows you what it will write and adds the component next to your own.
TypingDots.jsxtyping-dots.csstokens.cssREADME.md
Both files install together. The stylesheet reads the design tokens in tokens.css and carries fallbacks, so it also works alone.



