Skip to main content

Stream Text

AI-style streaming text reveal where chunks arrive with a short blur trail and a blinking caret cursor.

To give text real presence, combine a short blur trail with a subtle slide and steady cadence. Let each chunk settle cleanly without shifting the surrounding layout.

Customize

Chunk delay (ms)75
Blur (px)8

Installation

npx shadcn@latest add @kinetic/stream-text

Usage

Pass a string to text to simulate a chunked stream on mount, or switch trigger to "inView" or "manual".

import { StreamText } from "@/components/kinetic/ui/stream-text";

export function AssistantReply() {
  return (
    <StreamText
      text="Streaming responses arrive in short word chunks with a gentle blur settle."
      className="text-base text-foreground"
    />
  );
}

External streaming

Drive the reveal from a live stream by passing chunks as tokens arrive, or by growing text over time with streaming={true}. Set streaming={false} when the stream closes to hide the caret and fire onComplete.

import { StreamText } from "@/components/kinetic/ui/stream-text";

interface LiveAnswerProps {
  readonly text: string;
  readonly streaming: boolean;
}

export function LiveAnswer({ text, streaming }: LiveAnswerProps) {
  return <StreamText text={text} streaming={streaming} showCursor />;
}

Imperative control

Attach a ref typed as StreamTextHandle to restart or clear the stream programmatically. Calling play() restarts from the first chunk, and reverse() clears the revealed chunks.

import { useRef } from "react";
import { StreamText, type StreamTextHandle } from "@/components/kinetic/ui/stream-text";

export function ControlledStream() {
  const streamRef = useRef<StreamTextHandle>(null);

  return (
    <div className="space-y-3">
      <StreamText
        ref={streamRef}
        trigger="manual"
        text="Call play to stream from the start, or reverse to clear."
      />
      <div className="flex gap-2">
        <button type="button" onClick={() => streamRef.current?.play()}>
          Play
        </button>
        <button type="button" onClick={() => streamRef.current?.reverse()}>
          Clear
        </button>
      </div>
    </div>
  );
}

Motion preferences

Use chunkDelayMs, durationMs, blurPx (clamped to 8 px), and speed to tune pacing. Timing scales with data-tempo. Under reduced motion, the full text renders immediately without blur or timers, and the caret stops blinking.

API Reference

StreamText

Streaming text renderer supporting internal chunk simulation or controlled external streams.

PropTypeDefaultDescription
textstring-Full text to stream or growing controlled string.
streamingboolean-Enables external controlled streaming mode.
chunkDelayMsnumber75Base delay between chunks in simulated mode.
blurPxnumber8Blur trail radius for incoming chunks (max 8px).
showCursorbooleantrueShows a blinking caret while streaming.