An AI reply that develops into focus word by word, with markdown, a quiet caret, and a reply bar.
Press Replay to watch the answer arrive. Words arrive in small uneven bursts like a real model, pausing briefly at commas and full stops, and each burst sharpens out of a soft blur behind a small dot that glides along the line. Bold, code, lists, and links are formatted the moment they appear, never as raw symbols. Press Stop to cut it off. Once it finishes, copy it, retry it, or rate it.
Options you can pass to customize this component.
text*stringEverything received so far. Pass the growing string as it streams; markdown is supported.
statusstreamingdonestoppedStreaming reveals text as it arrives. Done finishes revealing what is left. Stopped freezes on what was shown.
speednumberAverage words per second once caught up. It speeds up while behind, so bursts never pile up.
inkstringAn optional color new words land in before they settle to the text color, also used for the dot. Unset, everything stays monochrome.
actionsbooleanShows copy and rating buttons once the reply settles.
onRetry() => voidAdds a retry button that calls this.
onFeedback(feedback: "up" | "down" | null) => voidCalled when a thumb is pressed, with null when it is pressed again to clear it.
defaultFeedback"up""down"nullThe rating to show on first render, like one saved earlier.
onCopy(text: string) => voidCalled with the copied text. After a stop, only the part that was shown is copied.
classNamestringExtra classes merged onto the root element (data-slot="streaming-response", with data-status). Font and color come from the parent.
npx shadcn@latest add swamimalode07/rare-ui/streaming-response"use client"import { StreamingResponse } from "@/components/ui/streaming-response"export function Reply({ text, done, onRetry }: { text: string; done: boolean; onRetry: () => void }) {return (<StreamingResponse// text grows as tokens arrive, like useChat's message contenttext={text}status={done ? "done" : "streaming"}onRetry={onRetry}onFeedback={(rating) => console.log(rating)}/>)}
Click the code icon in the top-right corner to view the source code.
Most components here are recreations of great work from around the web. I don't claim to be the original creator - this is my attempt to reverse-engineer, replicate, and often add a few extra features. I've tried to credit everyone; if I missed someone, let me know.
1
Why do springs feel better than easing curves?