Skip to content
AI Interfaces block

Streaming Answer with Citations

Token-by-token text with linked citations, follow-up chips and a caret that stops the moment the stream does. The status is announced once; the prose is deliberately outside every live region.

296 lineslucide-reactAdded 13 Aug 2026Updated 10 Sept 2026
  • streaming
  • citations
  • answer
  • typewriter
  • reduced motion

What's included

  • components/chat-streaming-answer.tsx
  • Needs lucide-react

Works with

  • React
  • Next.js
  • Tailwind CSS
  • TypeScript

npx hoverlab add chat-streaming-answer

Or over MCP, from your editor's agent — no account needed.

License

Free to read, copy and install, for personal and non-commercial projects. Shipping it in client work or a paid product needs Pro ($79 once). The source lands in your repo and stops being ours — no attribution, nothing to upgrade.

Was this useful?

Start a page with this section — add more, order them, and leave with the page source.

Preview

Why did churn spike in Q3?

Answer complete

Churn concentrated in accounts under 20 seats, which lost 6.1% of ARR against 1.4% in the rest of the book 1 — see source 1. The common thread is activation rather than price: teams that never connected a second data source churned at roughly four times the rate of those that did 2 — see source 2. Only 11% of the cancellations cited cost in their exit survey, and most of those had already downgraded once 3 — see source 3.

3 sources

Ask next

Rendered live in your current theme — this is the same component whose source is below, not a screenshot of it.

Source

components/chat-streaming-answer.tsx
/**
 * <ChatStreamingAnswer> — an answer that arrives a token at a time, with
 * inline citations, reply actions and follow-up chips.
 *
 * Streaming is where accessible chat quietly breaks, so the handling here is
 * the point of the block:
 *
 *  - The text is NOT in a live region. A region that re-reads on every
 *    mutation turns a 60-token answer into 60 announcements of a growing
 *    paragraph. Instead the streaming *status* is announced once from a
 *    separate `role="status"`, and the finished text is announced once when
 *    it settles — which is what a reader actually wants read to them.
 *  - `prefers-reduced-motion` skips the animation outright rather than
 *    slowing it. There is no information in watching characters appear; the
 *    answer is the information, and a user who asked for less motion should
 *    simply have it.
 *  - The caret blink is `motion-safe:` for the same reason, and disappears
 *    the moment the stream ends so it cannot be mistaken for a hung request.
 *
 * The mount-time reset runs in a layout effect, not `useEffect`. The server
 * render has to emit the *finished* answer — an exported HTML snapshot of an
 * empty paragraph is worthless — so the client starts full and rewinds to
 * zero, and doing that after paint would flash the whole answer for a frame.
 */

'use client'

import * as React from 'react'
import { Bot, Check, Copy, CornerDownRight, ExternalLink, RotateCcw } from 'lucide-react'

export interface AnswerSource {
  id: number
  title: string
  host: string
}

export interface ChatStreamingAnswerProps {
  /**
   * The prompt this answers, shown as a bubble above it. Pass an empty
   * string to drop it — inside an existing thread the question has already
   * been rendered, and repeating it puts the same sentence on screen twice.
   */
  question?: string
  /** The answer body. `[1]`-style markers are linked to `sources`. */
  answer?: string
  sources?: AnswerSource[]
  followUps?: string[]
  /** Milliseconds per character while streaming. */
  speed?: number
  className?: string
}

const DEFAULT_ANSWER =
  'Churn concentrated in accounts under 20 seats, which lost 6.1% of ARR against 1.4% in the rest of the book [1]. The common thread is activation rather than price: teams that never connected a second data source churned at roughly four times the rate of those that did [2]. Only 11% of the cancellations cited cost in their exit survey, and most of those had already downgraded once [3].'

const DEFAULT_SOURCES: AnswerSource[] = [
  { id: 1, title: 'Q3 revenue cohorts', host: 'warehouse.arr_monthly' },
  { id: 2, title: 'Activation funnel, Jul–Sep', host: 'warehouse.events' },
  { id: 3, title: 'Cancellation survey responses', host: 'support.exit_surveys' },
]

const DEFAULT_FOLLOW_UPS = [
  'Which integrations correlate with retention?',
  'Show the same cut for last quarter',
  'Draft a save offer for the at-risk accounts',
]

/**
 * `useLayoutEffect` on the client, `useEffect` on the server.
 *
 * React warns that a layout effect does nothing during SSR, and it is right —
 * but the warning fires even when the effect exists precisely to correct the
 * server's output before the browser paints it. Swapping the hook by
 * environment is the standard way out, and it is the only reason the rewind
 * below does not flash.
 */
const useIsomorphicLayoutEffect =
  typeof window === 'undefined' ? React.useEffect : React.useLayoutEffect

/*
  Per-instance id, hashed from props that differ between instances.

  A literal-rooted id is a latent duplicate the moment this block renders
  twice on one document. `aria-labelledby` resolves to whichever element
  with that id comes first, so the second copy is announced with the
  first copy's label. Server component, so no `useId` -- hashing props
  gives each instance its own namespace and stays stable across server and
  client renders in a way a counter would not.
*/
function instanceId(...parts: (string | undefined)[]): string {
  const text = parts.filter(Boolean).join('|')
  let hash = 0
  for (let i = 0; i < text.length; i++) hash = (Math.imul(hash, 31) + text.charCodeAt(i)) | 0
  return (hash >>> 0).toString(36).slice(0, 6)
}

export function ChatStreamingAnswer({
  question = 'Why did churn spike in Q3?',
  answer = DEFAULT_ANSWER,
  sources = DEFAULT_SOURCES,
  followUps = DEFAULT_FOLLOW_UPS,
  speed = 12,
  className = '',
}: ChatStreamingAnswerProps) {
  const uid = instanceId(question)

  // Starts complete: this is what the server renders and what a user with
  // reduced motion keeps.
  const [shown, setShown] = React.useState(answer.length)
  const [copied, setCopied] = React.useState(false)
  const [run, setRun] = React.useState(0)

  const streaming = shown < answer.length

  useIsomorphicLayoutEffect(() => {
    if (window.matchMedia('(prefers-reduced-motion: reduce)').matches) return
    setShown(0)
  }, [answer, run])

  React.useEffect(() => {
    if (!streaming) return
    // Several characters per tick rather than one per tick: a 16ms timer per
    // character makes a 400-character answer take six seconds and pins a
    // timer to every card on the page while it does.
    const id = window.setInterval(() => {
      setShown((n) => Math.min(n + 3, answer.length))
    }, speed)
    return () => window.clearInterval(id)
  }, [streaming, answer.length, speed])

  React.useEffect(() => {
    if (!copied) return
    const id = window.setTimeout(() => setCopied(false), 2000)
    return () => window.clearTimeout(id)
  }, [copied])

  async function copy() {
    try {
      await navigator.clipboard?.writeText(answer)
      setCopied(true)
    } catch {
      // Denied or unavailable — the answer is still selectable text.
    }
  }

  const visible = answer.slice(0, shown)

  return (
    <div className={`mx-auto w-full max-w-2xl p-6 ${className}`}>
      {question ? (
        <p className="mb-5 text-end text-sm">
          <span className="inline-block rounded-2xl rounded-ee-md bg-primary px-4 py-2.5 text-start text-primary-foreground">
            {question}
          </span>
        </p>
      ) : null}

      <div className="flex gap-3">
        <span
          aria-hidden
          className="mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-primary/10 text-primary"
        >
          <Bot className="h-4 w-4" />
        </span>

        <div className="min-w-0 flex-1">
          {/* Announced once, and only while it is true. The answer text
              itself is deliberately outside every live region. */}
          <span role="status" className="sr-only">
            {streaming ? 'Generating answer' : 'Answer complete'}
          </span>

          <div className="rounded-2xl rounded-es-md border border-border/60 bg-card px-4 py-3 text-sm leading-relaxed">
            <p>
              {renderWithCitations(visible, sources)}
              {streaming ? (
                <span
                  aria-hidden
                  className="ms-0.5 inline-block h-4 w-[2px] translate-y-0.5 bg-primary motion-safe:animate-pulse border border-transparent"
                />
              ) : null}
            </p>
          </div>

          {/* -- Sources ------------------------------------------------ */}
          <details className="group mt-2.5" open={!streaming}>
            <summary className="inline-flex cursor-pointer list-none items-center gap-1.5 rounded-lg px-2 py-1 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring">
              <CornerDownRight aria-hidden className="h-3.5 w-3.5 rtl:rotate-180" />
              {sources.length} sources
            </summary>

            <ul className="mt-1.5 space-y-1">
              {sources.map((source) => (
                <li key={source.id}>
                  <a
                    href="#"
                    id={`${uid}-citation-${source.id}`}
                    className="flex items-center gap-2.5 rounded-lg border border-border/60 bg-card/60 px-2.5 py-2 text-xs transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
                  >
                    <span className="flex h-5 w-5 shrink-0 items-center justify-center rounded-md bg-muted font-mono text-[10px] font-semibold">
                      {source.id}
                    </span>
                    <span className="min-w-0 break-words font-medium">{source.title}</span>
                    <span className="ms-auto min-w-0 break-words font-mono text-[11px] text-muted-foreground">
                      {source.host}
                    </span>
                    <ExternalLink aria-hidden className="h-3 w-3 shrink-0 text-muted-foreground" />
                  </a>
                </li>
              ))}
            </ul>
          </details>

          {/* -- Actions ------------------------------------------------ */}
          <div className="mt-2 flex items-center gap-1.5">
            <button
              type="button"
              onClick={copy}
              className="inline-flex items-center gap-1.5 rounded-lg border border-border/60 px-2.5 py-1.5 text-xs font-medium transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
            >
              {copied ? (
                <Check aria-hidden className="h-3.5 w-3.5 text-emerald-500" />
              ) : (
                <Copy aria-hidden className="h-3.5 w-3.5" />
              )}
              {copied ? 'Copied' : 'Copy'}
            </button>

            <button
              type="button"
              onClick={() => setRun((n) => n + 1)}
              className="inline-flex items-center gap-1.5 rounded-lg border border-border/60 px-2.5 py-1.5 text-xs font-medium transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
            >
              <RotateCcw aria-hidden className="h-3.5 w-3.5" />
              Regenerate
            </button>
          </div>

          {/* -- Follow-ups -------------------------------------------- */}
          {followUps.length > 0 && !streaming ? (
            <div className="mt-4">
              <p className="mb-2 text-xs font-semibold uppercase tracking-wider text-muted-foreground">
                Ask next
              </p>
              <ul className="flex flex-wrap gap-2">
                {followUps.map((text) => (
                  <li key={text}>
                    <button
                      type="button"
                      className="rounded-full border border-border/60 bg-card px-3 py-1.5 text-start text-xs transition-colors hover:border-primary/40 hover:bg-primary/5 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
                    >
                      {text}
                    </button>
                  </li>
                ))}
              </ul>
            </div>
          ) : null}
        </div>
      </div>
    </div>
  )
}

/**
 * Turn `[1]` markers into links to the source list below.
 *
 * Split rather than `dangerouslySetInnerHTML` — the answer text is model
 * output, which is the last string in the app that should be trusted as
 * markup. A citation whose number has no matching source is left as plain
 * text instead of linking to nothing.
 */
function renderWithCitations(text: string, sources: AnswerSource[]): React.ReactNode[] {
  const known = new Set(sources.map((s) => s.id))

  return text.split(/(\[\d+\])/g).map((part, i) => {
    const match = /^\[(\d+)\]$/.exec(part)
    const id = match ? Number(match[1]) : null

    if (id === null || !known.has(id)) return <React.Fragment key={i}>{part}</React.Fragment>

    return (
      <a
        key={i}
        href={`#citation-${id}`}
        // Leading margin only. A trailing one opens a visible gap before
        // the sentence's full stop, which reads as a typo.
        className="ms-0.5 inline-flex h-4 min-w-4 items-center justify-center rounded bg-primary/10 px-1 align-super font-mono text-[10px] font-semibold text-primary no-underline transition-colors hover:bg-primary/20 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
      >
        {id}
        <span className="sr-only"> — see source {id}</span>
      </a>
    )
  })
}

Before you paste

  • Styling is Tailwind utility classes on semantic tokens (bg-card, text-muted-foreground) — it inherits your theme instead of overriding it.
  • Install: npm i lucide-react
  • Every prop has a default, so it renders standalone before you wire it up.

Where it goes

Drop it at components/chat-streaming-answer.tsx and import it where you need the section:

import { ChatStreamingAnswer } from '@/components/chat-streaming-answer'

Customize

2 of this block’s props are simple enough to drive from here. Change them and the block below re-renders — it is the same component whose source is above, not a mock of it. Everything else it accepts is in the table underneath.

Props

Read out of the component’s own type and signature, so this cannot drift from the source below. Every prop has a default — the component renders standalone before you pass it anything.

PropTypeDefault
questionThe prompt this answers, shown as a bubble above it. Pass an empty string to drop it — inside an existing thread the question has already been rendered, and repeating it puts the same sentence on screen twice.string'Why did churn spike in Q3?'
answerThe answer body. `[1]`-style markers are linked to `sources`.stringDEFAULT_ANSWER
sourcesAnswerSource[]DEFAULT_SOURCES
followUpsstring[]DEFAULT_FOLLOW_UPS
speedMilliseconds per character while streaming.number12
classNamestring''

Not using React?

The same block rendered once to markup, wrapped as a file your framework compiles. Tailwind classes are framework-agnostic, so the design transfers intact — the behaviour does not.

This block is interactive. The markup below is its initial state with the event handlers stripped — you will need to re-wire the behaviour in your framework.

chat-streaming-answer.html
<!--
  Streaming Answer with Citations — markup from the Hoverlab catalog.

  This is the block rendered once to HTML and wrapped as a component
  file. It is not a port of the React source: the Tailwind classes carry
  the design, which is the part that took the work, and they are the same
  in every framework.

  This block is interactive in React and the handlers are NOT here.
  Buttons, toggles and menus render in their initial state and do
  nothing until you wire them up.
-->
<div class="mx-auto w-full max-w-2xl p-6 ">
  <p class="mb-5 text-end text-sm">
    <span class="inline-block rounded-2xl rounded-ee-md bg-primary px-4 py-2.5 text-start text-primary-foreground">Why did churn spike in Q3?</span>
  </p>
  <div class="flex gap-3">
    <span aria-hidden="true" class="mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-primary/10 text-primary">
      <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-bot h-4 w-4" aria-hidden="true">
        <path d="M12 8V4H8"></path>
        <rect width="16" height="12" x="4" y="8" rx="2"></rect>
        <path d="M2 14h2"></path>
        <path d="M20 14h2"></path>
        <path d="M15 13v2"></path>
        <path d="M9 13v2"></path>
      </svg>
    </span>
    <div class="min-w-0 flex-1">
      <span role="status" class="sr-only">Answer complete</span>
      <div class="rounded-2xl rounded-es-md border border-border/60 bg-card px-4 py-3 text-sm leading-relaxed">
        <p>Churn concentrated in accounts under 20 seats, which lost 6.1% of ARR against 1.4% in the rest of the book <a href="#citation-1" class="ms-0.5 inline-flex h-4 min-w-4 items-center justify-center rounded bg-primary/10 px-1 align-super font-mono text-[10px] font-semibold text-primary no-underline transition-colors hover:bg-primary/20 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring">1<span class="sr-only"> — see source 1</span></a>. The common thread is activation rather than price: teams that never connected a second data source churned at roughly four times the rate of those that did <a href="#citation-2" class="ms-0.5 inline-flex h-4 min-w-4 items-center justify-center rounded bg-primary/10 px-1 align-super font-mono text-[10px] font-semibold text-primary no-underline transition-colors hover:bg-primary/20 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring">2<span class="sr-only"> — see source 2</span></a>. Only 11% of the cancellations cited cost in their exit survey, and most of those had already downgraded once <a href="#citation-3" class="ms-0.5 inline-flex h-4 min-w-4 items-center justify-center rounded bg-primary/10 px-1 align-super font-mono text-[10px] font-semibold text-primary no-underline transition-colors hover:bg-primary/20 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring">3<span class="sr-only"> — see source 3</span></a>.</p>
      </div>
      <details class="group mt-2.5" open="">
        <summary class="inline-flex cursor-pointer list-none items-center gap-1.5 rounded-lg px-2 py-1 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-corner-down-right h-3.5 w-3.5 rtl:rotate-180" aria-hidden="true"><path d="m15 10 5 5-5 5"></path><path d="M4 4v7a4 4 0 0 0 4 4h12"></path></svg>3 sources</summary>
        <ul class="mt-1.5 space-y-1">
          <li>
            <a href="#" id="wze9qh-citation-1" class="flex items-center gap-2.5 rounded-lg border border-border/60 bg-card/60 px-2.5 py-2 text-xs transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring">
              <span class="flex h-5 w-5 shrink-0 items-center justify-center rounded-md bg-muted font-mono text-[10px] font-semibold">1</span>
              <span class="min-w-0 break-words font-medium">Q3 revenue cohorts</span>
              <span class="ms-auto min-w-0 break-words font-mono text-[11px] text-muted-foreground">warehouse.arr_monthly</span>
              <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-external-link h-3 w-3 shrink-0 text-muted-foreground" aria-hidden="true">
                <path d="M15 3h6v6"></path>
                <path d="M10 14 21 3"></path>
                <path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"></path>
              </svg>
            </a>
          </li>
          <li>
            <a href="#" id="wze9qh-citation-2" class="flex items-center gap-2.5 rounded-lg border border-border/60 bg-card/60 px-2.5 py-2 text-xs transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring">
              <span class="flex h-5 w-5 shrink-0 items-center justify-center rounded-md bg-muted font-mono text-[10px] font-semibold">2</span>
              <span class="min-w-0 break-words font-medium">Activation funnel, Jul–Sep</span>
              <span class="ms-auto min-w-0 break-words font-mono text-[11px] text-muted-foreground">warehouse.events</span>
              <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-external-link h-3 w-3 shrink-0 text-muted-foreground" aria-hidden="true">
                <path d="M15 3h6v6"></path>
                <path d="M10 14 21 3"></path>
                <path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"></path>
              </svg>
            </a>
          </li>
          <li>
            <a href="#" id="wze9qh-citation-3" class="flex items-center gap-2.5 rounded-lg border border-border/60 bg-card/60 px-2.5 py-2 text-xs transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring">
              <span class="flex h-5 w-5 shrink-0 items-center justify-center rounded-md bg-muted font-mono text-[10px] font-semibold">3</span>
              <span class="min-w-0 break-words font-medium">Cancellation survey responses</span>
              <span class="ms-auto min-w-0 break-words font-mono text-[11px] text-muted-foreground">support.exit_surveys</span>
              <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-external-link h-3 w-3 shrink-0 text-muted-foreground" aria-hidden="true">
                <path d="M15 3h6v6"></path>
                <path d="M10 14 21 3"></path>
                <path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"></path>
              </svg>
            </a>
          </li>
        </ul>
      </details>
      <div class="mt-2 flex items-center gap-1.5">
        <button type="button" class="inline-flex items-center gap-1.5 rounded-lg border border-border/60 px-2.5 py-1.5 text-xs font-medium transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-copy h-3.5 w-3.5" aria-hidden="true"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"></rect><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"></path></svg>Copy</button>
        <button type="button" class="inline-flex items-center gap-1.5 rounded-lg border border-border/60 px-2.5 py-1.5 text-xs font-medium transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-rotate-ccw h-3.5 w-3.5" aria-hidden="true"><path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"></path><path d="M3 3v5h5"></path></svg>Regenerate</button>
      </div>
      <div class="mt-4">
        <p class="mb-2 text-xs font-semibold uppercase tracking-wider text-muted-foreground">Ask next</p>
        <ul class="flex flex-wrap gap-2">
          <li>
            <button type="button" class="rounded-full border border-border/60 bg-card px-3 py-1.5 text-start text-xs transition-colors hover:border-primary/40 hover:bg-primary/5 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring">Which integrations correlate with retention?</button>
          </li>
          <li>
            <button type="button" class="rounded-full border border-border/60 bg-card px-3 py-1.5 text-start text-xs transition-colors hover:border-primary/40 hover:bg-primary/5 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring">Show the same cut for last quarter</button>
          </li>
          <li>
            <button type="button" class="rounded-full border border-border/60 bg-card px-3 py-1.5 text-start text-xs transition-colors hover:border-primary/40 hover:bg-primary/5 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring">Draft a save offer for the at-risk accounts</button>
          </li>
        </ul>
      </div>
    </div>
  </div>
</div>
  • This is rendered HTML, not a translation of the React source. The Tailwind classes carry the design and work in any framework.
  • It is one frame: the component in its initial state, with no props applied beyond the defaults.
  • This block is interactive in React — toggles, menus or form state. None of that survives here; the markup is the closed/default state and the handlers are gone. Re-wire them in your own framework.
  • Requires Tailwind, and the design tokens the classes reference (bg-card, text-muted-foreground, and so on). The template ZIPs ship a globals.css that defines them.

What each framework gets across the whole catalog — effects convert properly; this rung is markup.

For AI

The component, its props, the design tokens it expects and the command that installs it — as one prompt. Paste it into Claude, Cursor, v0 or ChatGPT and what they build around it will match the rest of the catalog instead of inventing its own system.

See the prompt

Used in these pages

Want the whole screen instead of this one section? Open a page and copy it entire.

7 more blocks in Agent Chat

All of them free to read, copy and install — no account, no locked tiles, no watermarked preview. The whole catalog is open, and so are the API and the CLI.

Browse Agent Chat

Shipping one commercially

Copying the code is free. Putting it in client work or a paid product is what Pro is for — the licence, not the access.

  • A commercial licence for everything in the catalog
  • Unlimited bundle exports, in Vue, Svelte and Tailwind
  • One payment — no subscription, nothing to renew
Pro — $79 once

More Agent Chat blocks

View category
Open the full page for this block

Assistant Thread with Composer

A scrolling conversation with per-turn actions, announced as a polite log restricted to additions — so a streaming reply is not re-read on every token — and auto-scroll that only pins when the user is already at the bottom.

Agent Chat253 lines1 dep
Open the full page for this block

Composer with @ Sources and / Commands

The trigger menus done properly: @ and / open only at a token boundary, the query is derived from the caret so the menu closes itself, and focus never leaves the textarea — the combobox pattern, not a floating div.

Agent Chat434 lines1 dep
Open the full page for this block

Assistant Starter Screen

The blank thread, answered: grouped starter prompts as real lists of buttons, each group labelled, so the highest-leverage screen in an AI product is not a centred logo.

Agent Chat138 lines1 dep
Open the full page for this block

Message Version Switcher

The answers a regenerate throws away — siblings rather than replacements, an edited question that branches in place, and a plain sentence about what happens to the replies below.

Agent Chat272 lines1 dep
Open the full page for this block

Chat Beside a Canvas

The two-pane assistant layout, with the mismatch nobody else states: the canvas names the version it is showing and says so when that is not the one the conversation is about. Versions link back to the turn that made them.

Agent Chat321 lines1 dep
Open the full page for this block

Model Picker with Trade-offs

Model selection with the three numbers the choice actually turns on — capability, latency and cost per message — and locked models explained rather than greyed out.

Agent Chat267 lines1 dep
Open the full page for this block

Prompt Attachment Tray

Files staged against a prompt with a running context-token budget, unreadable files flagged before send, removal allowed mid-upload, and a send button that names its one blocker.

Agent Chat269 lines1 dep