"use client"
import { useEffect, useState } from "react"
import { Response } from "@/components/ui/response"
const tokens = [
"### Welcome",
"\n\n",
"This",
" is",
" a",
" **rich",
" markdown",
"**",
" showcase",
" with",
" multiple",
" features.",
"\n\n",
"---",
"\n\n",
"## Data Table",
"\n\n",
"| Name",
" | Role",
" | Status",
" |",
"\n",
"|------|------|--------|",
"\n",
"| Alice",
" | Engineer",
" | Active",
" |",
"\n",
"| Bob",
" | Designer",
" | Active",
" |",
"\n",
"| Carol",
" | PM",
" | Active",
" |",
"\n\n",
"## Inspiration",
"\n\n",
"> *Simplicity",
" is",
" the",
" ultimate",
" sophistication.*",
"\n",
"> —",
" Leonardo",
" da",
" Vinci",
"\n\n",
"## Inline",
" and",
" Block",
" Code",
"\n\n",
"Use",
" `let",
" total",
" =",
" items.length`",
" to",
" count",
" elements.",
"\n\n",
"```",
"python",
"\n",
"def",
" greet(name):",
"\n",
" return",
' f"Hello, {name}!"',
"\n",
'print(greet("World"))',
"\n",
"```",
"\n\n",
"## Math",
"\n\n",
"Inline",
" math:",
" $a^2",
" +",
" b^2",
" =",
" c^2$",
".",
"\n\n",
"Displayed",
" equation:",
"\n\n",
"$$",
"\n",
"\\int_0^1",
" x^2",
" dx",
" =",
" \\frac{1}{3}",
"\n",
"$$",
"\n\n",
]
const Example = () => {
const [content, setContent] = useState("")
useEffect(() => {
let currentContent = ""
let index = 0
const interval = setInterval(() => {
if (index < tokens.length) {
currentContent += tokens[index]
setContent(currentContent)
index++
} else {
clearInterval(interval)
}
}, 100)
return () => clearInterval(interval)
}, [])
return (
<div className="h-full min-h-0 w-full overflow-hidden">
<Response className="h-full overflow-auto p-10">{content}</Response>
</div>
)
}
export Example
Installation
pnpm dlx @elevenlabs/agents-cli@latest components add response
Usage
import { Response } from "@/components/ui/response"
Basic Usage
<Response>This is a simple text response.</Response>
With Markdown
The Response component supports full markdown rendering:
<Response>
{`# Heading
This is a paragraph with **bold** and *italic* text.
- List item 1
- List item 2
- List item 3
\`\`\`javascript
const greeting = "Hello, world!"
console.log(greeting)
\`\`\`
`}
</Response>
Streaming Response
Perfect for streaming AI responses character-by-character:
const [response, setResponse] = useState("")
// As tokens arrive, append to response
const handleStream = (token: string) => {
setResponse((prev) => prev + token)
}
return <Response>{response}</Response>
With Message Component
import { Message, MessageAvatar, MessageContent } from "@/components/ui/message"
import { Response } from "@/components/ui/response"
;<Message from="assistant">
<MessageAvatar src="/ai-avatar.jpg" name="AI" />
<MessageContent>
<Response>{streamingResponse}</Response>
</MessageContent>
</Message>
API Reference
Response
A memoized wrapper around Streamdown that renders streaming markdown with smooth animations.
Props
Extends all props from the Streamdown
component.
Prop | Type | Description |
---|---|---|
children | ReactNode | Content to render (markdown) |
className | string | Optional CSS classes |
...props | Streamdown | All Streamdown component props |
Notes
- Built on top of
streamdown
for smooth markdown streaming animations - Automatically removes top margin from first child and bottom margin from last child for clean integration
- Memoized to prevent unnecessary re-renders - only updates when children change
- Supports full markdown syntax including code blocks, lists, tables, and more
- Optimized for streaming AI responses with character-by-character rendering
- Works seamlessly with the Message component
- This component is inspired by Vercel's AI SDK Response component with modifications for ElevenLabs UI
Deploy and Scale Agents with ElevenLabs
ElevenLabs delivers the infrastructure and developer experience you need to ship reliable audio & agent applications at scale.
Talk to an expert