Skip to content

Streaming Text

Tegaki can animate text as it arrives from a streaming API, as in an AI chat interface.

Use uncontrolled mode: it follows the growing text and writes new characters as they arrive. The catchUp option speeds up playback when there’s buffered text, so the animation stays close to the stream without jumping.

import { TegakiRenderer } from 'tegaki';

function StreamingMessage({ text, font }) {
  return (
    <TegakiRenderer
      font={font}
      time={{ mode: 'uncontrolled', speed: 4, catchUp: 0.5 }}
    >
      {text}
    </TegakiRenderer>
  );
}

Update text as chunks arrive from your API. The renderer writes whatever is new.

  • speed: base playback speed multiplier (default 1). Higher values write faster.
  • catchUp: how hard the animation speeds up to close the gap when text arrives faster than it can be drawn. 0 disables catch-up (default). Typical range: 0.2 to 2.

See the streaming chat on the homepage for a live example.