Ir al contenido
Español

Cómo funciona

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.

Úsalo para

  • 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).

Busca otra opción cuando

  • 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.

Uso

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" />

Propiedades

PropiedadTipoPor defectoQué hace
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).
bubblebooleantrueDraws 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.
labelstring'Typing'Screen-reader text, such as "Support is typing" or "AI is thinking".
durationnumber1200Length of one round in ms. Below 900 is not recommended.
...restHTMLAttributes<HTMLSpanElement>—Other attributes go to the root, such as className and style. The dots follow the root's color.

Accesibilidad

  • 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.

Movimiento

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.

Añádelo a tu proyecto

Copia la instrucción en Codex o Claude Code. El agente lee el código publicado, te muestra lo que va a escribir y añade el componente junto a los tuyos.

TypingDots.jsxtyping-dots.csstokens.cssREADME.md

Los dos archivos se instalan juntos. La hoja de estilos lee las variables de tokens.css y lleva valores de reserva, así que también funciona sola.

Carga
Revelado de imagen viene con Pro. La vista previa aparece al desbloquearlo.
Cargador orbital viene con Pro. La vista previa aparece al desbloquearlo.