Streaming text
Feed it a bursty token stream and it reveals the reply at a steady reading pace, a whole word at a time, with bold, inline code, lists and a caret while it writes.
npx shadcn@latest add @captain/streaming-textThe checkout test keeps failing on CI but passes locally. Can you find out why?
Streaming text is a Pro component
The demo and the docs are free. The source comes with Pro, through this page, the shadcn CLI and the MCP.
Usage
import { StreamingText } from "@/components/ui/streaming-text"
const { messages, status } = useChat()
const last = messages.at(-1)
<StreamingText text={textOf(last)} done={status === "ready"} />Props
| Prop | Type | Default | What it does |
|---|---|---|---|
| text | string | Everything received so far. Append as tokens arrive, for example the text of the last message from useChat. | |
| done | boolean | false | Set when the stream ends. The reveal catches up, then the caret goes. |
| pace | number | 60 | Characters per second when the buffer is nearly empty. A burst drains in about 0.6s. |
| onRevealed | () => void | Called once the last word is on screen. |
Accessibility
- The reply is an aria-live region marked aria-busy while it streams, so screen readers read it once, whole, instead of word by word.
- Reduced motion keeps the fade and drops the blur and the lift.
- The caret is decorative and hidden from assistive tech.