AI/Streaming Text

StreamingText

Renders text token by token with configurable speed, smooth cursor animation, and an onComplete callback. Perfect for LLM streaming responses.

import { StreamingText } from "@animui/ui"

Live preview

With real streaming API

Set speed=0 when appending tokens externally from a ReadableStream — StreamingText will render each update immediately without adding additional delay.

"use client";

import { StreamingText } from "@animui/ui";
import { useState } from "react";

export default function Page() {
  const [text, setText] = useState("");

  const handleFetch = async () => {
    const res = await fetch("/api/generate");
    const reader = res.body!.getReader();
    const decoder = new TextDecoder();
    setText("");

    while (true) {
      const { done, value } = await reader.read();
      if (done) break;
      setText((t) => t + decoder.decode(value));
    }
  };

  return (
    <div>
      <StreamingText text={text} speed={0} cursor />
      <button onClick={handleFetch}>Generate</button>
    </div>
  );
}

Props

PropTypeDefaultDescription
textstringThe full text string to animate. Characters are revealed progressively.
speednumber18Milliseconds between each character. Set to 0 to render instantly (for real streaming where text grows externally).
cursorbooleantrueShows a blinking cursor at the end of the displayed text while streaming.
animatebooleantrueIf true, re-animates whenever text changes.
onComplete() => voidCalled when all characters have been displayed.
classNamestringAdditional classes on the text container.
© 2026 Steal Shadow. MIT License.Report an issue