AI Response Stream
motiq/ai-response-streamFreeComponent
Renders a streaming assistant response supplied by your app — text, fenced code with copy, inline [n] citations to a sources rail, and streaming/stopped/complete/error states with Stop, Retry, and Copy. Presentation only: it never calls a model. Reduced-motion shows text instantly; a polite live region announces completion, not tokens.
Live preview
live · rendered by the registry
Rendered by motiq on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://www.motiq.dev/r/ai-response-stream.jsonSource
1"use client";23import * as React from "react";4import { motion, AnimatePresence } from "motion/react";56import { cn } from "@/lib/utils";7import { useReducedMotion } from "@/lib/motiq";89/**10 * AiResponseStream — renders a streaming assistant response supplied by the11 * parent application (text, fenced code, inline citations, and lifecycle12 * state). It is a *presentation* component: it never talks to a model, never13 * fabricates tokens, and makes no claim about what an AI is "doing" — the app14 * owns the stream and passes the segments + state in.15 *16 * Accessibility: the rendered content is real, readable text (not aria-hidden),17 * so once the response is complete a screen reader reads the whole thing in one18 * pass. A separate polite `role="status"` region announces lifecycle changes19 * (responding / complete / stopped / failed) — never token-by-token, so the20 * live region is not spammed. State is conveyed with icon + label + border, not21 * colour alone, so it survives forced-colors. Stop / Retry / Copy are real22 * <button>s with accessible names and focus-visible rings. Under23 * `prefers-reduced-motion` there is no per-token motion and no caret: content24 * appears immediately. Clean-room original.25 */2627export type StreamState = "streaming" | "stopped" | "complete" | "error";2829/** A source referenced by inline `[n]` citation markers. */30export interface StreamSource {31 /** Stable id referenced by a `citation` segment's `sourceId` (e.g. "1"). */32 id: string;33 /** Human-readable title shown in the sources rail. */34 title: string;35 /** Optional external URL. Rendered as a real link when present. */36 url?: string;37 /** Optional one-line context shown under the title. */38 snippet?: string;39}4041/** Ordered content the parent streams in. Text may contain blank-line paragraph breaks. */42export type ResponseSegment =43 | { type: "text"; text: string }44 | { type: "code"; code: string; lang?: string; filename?: string }45 | { type: "citation"; sourceId: string };4647export interface AiResponseStreamProps {48 /** Ordered response segments supplied by the application. */49 segments: ResponseSegment[];50 /** Lifecycle state, owned by the application. */51 state: StreamState;52 /** Sources referenced by inline citations; rendered as a numbered rail. */53 sources?: StreamSource[];54 /** Label shown in the header (e.g. the assistant/model display name). */55 assistantName?: string;56 /** Message shown in the error banner when `state === "error"`. */57// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from motiq
All 100 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Activity Streamactivity-stream | motiq | Components | Free | 1 dep | |
| Adaptive Safe-Zone Gridadaptive-safe-zone-grid | motiq | Components | Free | no deps | |
| Agent Run Timelineagent-run-timeline | motiq | Components | Free | 1 dep | |
| Animated Accordionanimated-accordion | motiq | Components | Free | 2 deps | |
| Animated Buttonanimated-button | motiq | Components | Free | 1 dep | |
| Animated Dialoganimated-dialog | motiq | Components | Free | 2 deps | |
| Animated Gridanimated-grid | motiq | Components | Free | 2 deps | |
| Animated Iconsanimated-icons | motiq | Components | Free | 1 dep |
