本文へ移動
日本語

仕組み

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.

向いている場面

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

向かない場面

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

使い方

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

プロパティ

プロパティ型既定値説明
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.

アクセシビリティ

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

モーション

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.

プロジェクトに追加

プロンプトを Codex または Claude Code に貼り付けます。エージェントが公開ソースを読み、書き込む内容を示したうえで、既存のコンポーネントの隣に追加します。

TypingDots.jsxtyping-dots.csstokens.cssREADME.md

2 つのファイルを一緒に導入します。スタイルは tokens.css の変数を読み、予備の値も持つため、単体でも表示できます。

読み込み
「画像リビール」は Pro に含まれます。解除するとプレビューが表示されます。
「オービットローダー」は Pro に含まれます。解除するとプレビューが表示されます。