Streaming Text

Progressive text surface for token-by-token model output during a stream.

StreamingText is the live answer surface. Pass growing text from your stream, keep isStreaming true while tokens arrive, and the caret marks the live edge. Pair it with Bubble for the message chrome and Thinking for reasoning.

Installation

pnpm dlx cubix@latest add streaming-text --base radix

Usage

Import
import { StreamingText } from "@/components/cubix/streaming-text"
Example
<StreamingText isStreaming={isStreaming}>
  {text}
</StreamingText>

Note: StreamingText does not own the transport. Your chat hook appends tokens; this component renders the progressive text and caret.

Composition

 
StreamingText
└── StreamingTextCaret

Features

  • Renders growing token output from your stream
  • Built-in block, line, and circle carets
  • Hides the caret automatically when streaming ends
  • Supports multiline plain text with preserved newlines
  • Composable custom caret slot
  • Accessible live region while tokens arrive
  • Fits inside Bubble and Message rows

Completed reply

When the stream is done, set isStreaming={false} so the caret disappears.

Start with the changelog, run the smoke suite, migrate before cutover, then watch error rate and p95 latency for the first hour.

Waiting for tokens

Before the first character arrives, keep isStreaming true with empty content so the caret still shows activity.

Waiting for the first token.

Caret styles

Choose block, line, or circle - or disable the automatic caret.

line

block

circle

none

Custom caret

Set caret={false} and compose StreamingTextCaret yourself.

Multiline

Newlines are preserved with whitespace-pre-wrap.

Stopped mid-stream

Keep the partial text when the reader stops generation.

Interrupted stream

Show the truncated reply with an error and retry action below.

Deploy looks healthy. Error rate is flat, p95 is under

Stream interrupted before the reply completed.

Inside a message

Nest StreamingText inside BubbleContent and switch footer actions between Stop and Retry.

With Thinking

Run Thinking first, then stream the answer text in the bubble.

 

API Reference

StreamingText

PropTypeDefaultDescription
isStreamingbooleanfalseWhen true, marks the surface as live and shows the caret unless disabled.
caret"block" | "line" | "circle" | false"line"Built-in caret style, or false to hide the automatic caret.
childrenReact.ReactNode-Streamed text or composed content. Grows as tokens arrive.
classNamestring-Additional classes for the streaming text root.

StreamingTextCaret

PropTypeDefaultDescription
variant"block" | "line" | "circle""line"Built-in caret appearance when rendering without children.
forcebooleanfalseRender even when the parent is not streaming. Useful for custom previews.
childrenReact.ReactNode-Optional custom caret contents instead of the built-in shape.
classNamestring-Additional classes for the caret.