Skip to content

AI interfacesLumen Halo

Streaming TextProv1.0.0

A reply arriving word by word: each new word settles in from a faint blur and a calm caret breathes at the end. Feed it your growing text, an async stream of chunks, or a whole string to reveal; screen readers hear phrases, and reduced motion shows the text at once.

Built on shadcn/ui

.md
pnpm dlx shadcn@latest add @beautiful-ui-pro/lumen-streaming-text

Needs your registry key. Your components.json style picks the Base UI or Radix build: radix-*, new-york and default get Radix, base-* gets Base UI.

Styles didn't apply?

The CLI adds the styles to the CSS file named in components.json (tailwind.css). Check that it points at your global stylesheet, that the project uses Tailwind CSS v4, and that the file is imported in your root layout. Installed by hand: paste styles.css into that file.

Set up the Beautiful UI registry

Free pieces install from their URL with no setup (that URL gives the Base UI build; Radix projects use /r/radix-nova/<name>.json, or add the registries below and the CLI picks your build). Pro pieces need the registries below and BEAUTIFUL_UI_TOKEN in .env.local.

components.json
{
  "registries": {
    "@beautiful-ui": "https://beautiful-ui.dev/r/{style}/{name}.json",
    "@beautiful-ui-pro": {
      "url": "https://beautiful-ui.dev/r/pro/{style}/{name}.json",
      "headers": { "Authorization": "Bearer ${BEAUTIFUL_UI_TOKEN}" }
    }
  }
}

MCP server

claude mcp add --transport http beautiful-ui https://beautiful-ui.dev/api/mcp
Catalog for agents: /llms.txt

Usage

Import it and pass your content. The props that matter most are listed next.

Example
"use client";

import * as React from "react";
import { StreamingText } from "@/components/ui/lumen/controls/streaming-text";

// The text grows as your stream arrives (useChat, a reducer, a fetch reader).
export function Answer({ text, streaming }: { text: string; streaming: boolean }) {
  return <StreamingText text={text} streaming={streaming} className="text-sm leading-6" />;
}

// Or hand it the stream itself: an async iterable of chunks.
export async function* chunks(res: Response) {
  const reader = res.body!.pipeThrough(new TextDecoderStream()).getReader();
  try {
    for (;;) {
      const { value, done } = await reader.read();
      if (done) return;
      yield value;
    }
  } finally {
    // Stopping early (unmount, a new question) releases the response.
    void reader.cancel().catch(() => {});
  }
}

export function StreamedAnswer({ res }: { res: Response }) {
  // A response body can be read once: make the iterable once per response, not on every render.
  const source = React.useMemo(() => chunks(res), [res]);
  return (
    <StreamingText
      source={source}
      onDone={(t) => console.log("complete", t.length)}
      onStreamError={(error, partial) => console.error("stream failed after", partial.length, "characters", error)}
    />
  );
}

Props

  • text / streaming–

    string / boolean

    The text so far as your stream grows (useChat, a reducer), and whether more is coming.

  • source–

    string | AsyncIterable<string>

    Instead of text: an async iterable of chunks (read once, safe under Strict Mode), or a whole string revealed at speed.

  • speed32

    number

    Words per second when source is a string.

  • carettrue

    boolean

    The breathing caret while streaming.

  • announce / announceMstrue / 1200

    boolean / number

    Read phrases to screen readers at most this often. Turn off inside a live log (Conversation already announces).

  • onDone–

    (text: string) => void

    Called once when the text completes.

Show all 7 props
  • onStreamError–

    (error, text) => void

    The source failed part-way: what arrived stays, onDone isn't called.

Source

components/ui/lumen/controls/streaming-text.tsx

This component is included with Pro.

Try the live preview above. Get Pro to install the source.