Shadcn Streaming Response Components

A wrapper for AI assistant replies that grows while the model is writing and keeps its layout stable when it finishes: copy, retry, helpful and not helpful feedback and a collapsible list of cited sources fade in once the answer is complete. Works with plain text, rendered markdown and Streaming Code blocks. Browse our collection of 8 Shadcn Streaming Response variants.

Basic

Copy, retry and feedback

Yes, you can pause the subscription instead of cancelling it. Open Billing, choose Pause plan and pick one, two or three months. Your projects and data stay in place, and billing resumes automatically on the date you choose.

Rate the answer or retry for a new one.

Support assistant

With sources

Research assistant

Thinking state

Thinking...

Analytics assistant

Rich content with code

Coding assistant

Error with retry

Customer support

Inside a chat conversation

I am going to Lisbon for a long weekend in April. What should I pack?
Travel assistant

AI assistant

Stop generation

AI chat
Unlock premium components
Get full control of shadcn/ui components, blocks and instances, including future additions.

Explore Shadcn Blocks

Ready-made page sections built with the same components.

View all blocks

Shadcn Streaming Response Component

The Shadcn Streaming Response component wraps an AI assistant reply while the model is still writing it. The text grows in place, and when the answer is complete a row of actions fades in below it: copy, retry, helpful and not helpful feedback and a collapsible list of the sources the answer cites.

The examples cover a basic word by word stream, a finished answer with copy, retry and feedback, cited sources with numbered markers, a Thinking state before the first token, rich content with a list, inline code, a link and a Streaming Code block, an error with retry, a reply inside a chat conversation and a Stop button that halts generation. It is built from shadcn/ui Button, Toggle, Tooltip, Collapsible, Avatar and Item, styled with Tailwind CSS.

What is the Shadcn Streaming Response Component?

A streaming response is the container for one assistant message. It does not fetch or stream text itself: you pass the text received so far, or rendered markdown, as children and set status to streaming, complete or error. The component styles paragraphs, links, inline code, lists and code blocks inside it and decides which actions are available in each phase.

Use it for chat assistants, support bots, research tools and any screen where a model answers in front of the user. For code that streams line by line, put a Streaming Code block inside the response.

Anatomy of the Shadcn Streaming Response

PartDescription
StreamingResponseThe only export. It renders the content area and, once status is no longer streaming, the action row. The root carries data-state with the current status.
ContentYour children in a text-sm leading-6 area that spaces blocks and styles links, inline code, ordered and unordered lists and plain pre blocks. Add classes with contentClassName.
Copy and RetryIcon buttons with tooltips. Copy writes copyText (or the rendered text) to the clipboard and shows a check for 1.6 seconds. Retry appears only when you pass onRetry.
Helpful and Not helpfulTwo toggles shown when the answer is complete. Only one can be pressed, and pressing the active one clears it. Control them with feedback and onFeedbackChange.
SourcesA button with up to three overlapping source initials and a count label that opens a numbered list of citations. Each row shows the title, the domain and an external link icon, and opens in a new tab.

8 Shadcn Streaming Response Variants

Each streaming response variant listed here is previewed live at the top of this page, together with its source code and install command.

  • Basic: Two paragraphs revealed word by word, with a Replay button below the response.
  • Copy, retry and feedback: A finished support answer with controlled feedback, a short thank you note and Retry that streams the answer again.
  • With sources: Numbered markers in the text link to the cited pages, and the Sources button lists all four citations.
  • Thinking state: A shimmering Thinking label before the first word arrives, then the streamed answer.
  • Rich content with code: Intro text, a numbered list with inline code, a Streaming Code block and a closing link, all streamed in order.
  • Error with retry: The first attempt stops halfway with an error message, and Retry streams the full answer.
  • Chat conversation and stop: A user Bubble followed by an assistant Message with sources, and a Stop button that ends the stream and shows the actions for the partial answer.

How to Install the Shadcn Streaming Response Component

Set up shadcn/ui in your project if you have not already, then add the Shadcn UI Kit registry to your components.json once:

{
  "registries": {
    "@shadcnuikit": "https://shadcnuikit.com/r/{name}.json"
  }
}

Then install a streaming response variant by its name:

npx shadcn@latest add @shadcnuikit/streaming-response1

The same command works with pnpm dlx, yarn dlx and bunx --bun. Each variant has a copy button for every package manager, and the code is added to your project as plain React and Tailwind CSS that you can edit freely.

How to Use the Shadcn Streaming Response Component

Keep the streamed text in state and map your request phase to status. The actions appear on their own when the stream ends.

import { StreamingResponse } from "@/components/ui/streaming-response"

export function AssistantReply({
  text,
  done,
  onRetry,
}: {
  text: string
  done: boolean
  onRetry: () => void
}) {
  return (
    <StreamingResponse
      status={done ? "complete" : "streaming"}
      copyText={text}
      onRetry={onRetry}
    >
      <p>{text}</p>
    </StreamingResponse>
  )
}

Why Use the Shadcn Streaming Response Component

  • Stable layout: The content area does not change size when the stream ends. The action row is added below it with a short fade, so the answer does not jump.
  • Actions at the right time: Copy, retry and feedback are hidden while the model writes, so users never copy or rate half an answer.
  • Citations built in: Pass a sources array and get a compact source button and a numbered list with titles, domains and external links.
  • Works with any content: Plain text, markdown rendered to JSX and Streaming Code blocks all sit inside the same styled content area.
  • Theme aware: Every color comes from your theme tokens, so the response matches light and dark mode and any theme from the Theme Generator.

Common Streaming Response Use Cases

  • AI chat assistants: Replies that stream into a conversation with feedback.
  • Support bots: Answers with retry when a connection drops.
  • Research tools: Summaries that cite and link their sources.
  • Coding assistants: Explanations with inline code and streamed files.
  • Analytics copilots: A Thinking state while a query runs, then the answer.

Customizing the Shadcn Streaming Response

Rename every action with labels, including the error message and the singular and plural source labels. Hide the row with showActions={false}, and pass className, contentClassName or actionsClassName to restyle each part.

Feedback and the sources list can be controlled or uncontrolled. Use feedback with onFeedbackChange to save ratings, and sourcesOpen with onSourcesOpenChange to open the list from outside:

<StreamingResponse
  status="complete"
  feedback={feedback}
  onFeedbackChange={setFeedback}
  sources={[
    { title: "Core Web Vitals", url: "https://web.dev/articles/vitals" },
    { title: "useTransition", url: "https://react.dev/reference/react/useTransition" },
  ]}
  defaultSourcesOpen
  labels={{ copy: "Copy answer", sources: "references" }}
>
  <p>{answer}</p>
</StreamingResponse>

Streaming Response Accessibility and Keyboard Support

While streaming, the root sets aria-busy and the content is a polite live region, so screen readers wait for the answer instead of reading every token. Pass announce={false} to turn the live region off when another part of the page announces the reply.

Icon buttons have an aria-label and a tooltip, the feedback toggles expose aria-pressed, and the sources button uses aria-expanded and aria-controls. Icons are hidden from assistive technology, and under reduced motion the action row fades in without sliding and the sources list opens without animation.

KeyAction
TabMoves focus through copy, retry, feedback and sources.
Enter or SpaceCopies, retries, toggles feedback or opens the sources.
Tab inside sourcesMoves through the citation links.

Streaming Response Best Practices

  • Set status to streaming only while the request is open, and switch to complete or error as soon as it closes.
  • Pass copyText with the original markdown so users copy clean text rather than the rendered layout.
  • Show a Thinking state before the first token so the reply never looks empty.
  • Keep partial text visible on error and offer Retry, so users do not lose what was already written.
  • Use Streaming Code for code inside a reply instead of a plain pre block.

Shadcn Streaming Response for AI Agents

Streaming Response gives an agent one wrapper for every assistant reply: the partial text or rendered markdown goes in as children, status moves from streaming to complete or error, and copy, retry, helpful and not helpful feedback and a numbered sources list appear only when the answer is done. It also hosts Streaming Code blocks, a Thinking shimmer before the first token and partial answers after a Stop.

Install it with an AI agent

Claude Code, Cursor, Codex and other agents can install these with the shadcn CLI, for example npx shadcn@latest add @shadcnuikit/streaming-response1. With the Shadcn UI Kit MCP server, your agent can search every variant by name and add the right one for you. To give it full context, share /components/streaming-response.md, the Markdown version of this page with every variant and install command.

Example prompts

  • “Wrap every assistant message in our chat with StreamingResponse, mapping the stream state to status and passing the raw markdown as copyText.”
  • “Save thumbs up and thumbs down ratings from StreamingResponse feedback to our ratings endpoint, keyed by message id.”
  • “Show the citations from our search tool as StreamingResponse sources and link the [1] markers in the answer to the same URLs.”

Customize it with AI

Ask the agent to compose StreamingResponse rather than building a custom action row, and to control feedback and sourcesOpen when they must persist. The component does not parse markdown, so render it to JSX first and keep code fences in Streaming Code. Set status to error on a failed request and pass onRetry, and keep the partial text visible so the user does not lose it.

Components Related to Streaming Response

Shadcn Streaming Response FAQ

Keep the text received so far in state, render it as children of StreamingResponse and set status to streaming until the stream closes. Then set status to complete and the copy, retry and feedback actions appear.

No. It styles the content you pass, including paragraphs, links, inline code, lists and pre blocks, so you can render markdown with the library you already use or write the JSX yourself.

The thumbs up and thumbs down toggles appear when status is complete. Pass feedback and onFeedbackChange to save the rating; the value is helpful, not-helpful or null when the user clears it.

Pass a sources array with a title and url for each citation. The response shows a button with up to three source initials and a count, and opens a numbered list of links that open in a new tab.

Set status to error to show an error message with Copy and Retry next to the partial text. To stop generation, stop updating the text and set status to complete, and the actions appear for the partial answer.

Yes. Claude Code, Cursor, Copilot and other assistants can add a streaming response variant with the shadcn CLI or the shadcn MCP server, for example npx shadcn@latest add @shadcnuikit/streaming-response1. With a Pro plan, the Shadcn UI Kit MCP server can also build complete sections and pages around it.

Open /components/streaming-response.md to get this page as Markdown, with every streaming response variant, its description and install command. Paste the link or the text into your AI tool so it uses the real component code instead of guessing.

Looking for something else? Browse all shadcn/ui components or ready-made UI blocks built with them.