Streaming Text

Streamed answer with inline sources, actions, and follow-ups.

Installation

pnpm dlx shadcn@latest add @ward/streaming-text

Add the Ward registry to components.json once:

"registries": {
  "@ward": "https://ward.so/r/{name}.json"
}

Or install from the URL with no configuration: npx shadcn@latest add https://ward.so/r/streaming-text.json

Usage

import StreamingText from "@/components/ward/StreamingText";
<StreamingText
  loop={false}
  fill
  content={[{ text: "Sales" }, { text: "rose" }, { text: "23%." }, { text: "", cite: true }]}
  sources={[{ name: "Work Data", domain: "example.com", href: "https://example.com", image: "/sources/work.png" }]}
  followUps={["Break it down by region"]}
  onFollowUp={(text) => console.log(text)}
/>

Props

PropTypeDefaultDescription
variantstring"Default"Accepted for registry parity; StreamingText has no visual variants.
contentStreamingToken[]TOKENSTokens streamed in one at a time, where a token with cite set renders an inline chip for the first source.
sourcesStreamingSource[]SOURCESCited sources shown in the inline chip, the avatar stack and the expandable sources list.
followUpsstring[]FOLLOW_UPSFollow-up prompts listed once the stream completes.
labelsPartial<StreamingLabels>-Overrides for the sources toggle label and the follow-ups heading.
loopbooleantrueRestarts the stream after a pause; turn it off when embedding in a real thread.
fillbooleanfalseFills the parent width instead of using the fixed gallery width.
onDone() => void-Called when the stream finishes, but only when loop is off.
onFollowUp(text: string, index: number) => void-Called with the prompt text and its index when a follow-up is chosen.

Ward · Version 1.1.0 · Registry manifest