AI Result Preview
AI
Results
Block
Live preview component for AI-generated content. Supports markdown, code, HTML, and table rendering with raw/preview toggle, copy, download, and streaming indicators.
Markdown Preview
Document preview with parsed markdown
Project Summary
Project Summary
Overview
The application uses a modern React architecture with server-side rendering.
Key Features
This project follows industry best practices for scalability and maintainability.
Performance Metrics
Code Preview
Code block with syntax display
Custom Hook
TypeScript
import { useState, useEffect } from 'react'
interface User {
id: string
name: string
email: string
}
export function useUser(userId: string) {
const [user, setUser] = useState<User | null>(null)
const [loading, setLoading] = useState(true)
useEffect(() => {
fetch(`/api/users/${userId}`)
.then(res => res.json())
.then(data => {
setUser(data)
setLoading(false)
})
}, [userId])
return { user, loading }
}Table Preview
Auto-parsed table from pipe-delimited data
Phone Comparison
| Name | Category | Price | Rating |
|---|---|---|---|
| iPhone 15 Pro | Smartphone | $999 | 4.7 |
| Samsung S24 | Smartphone | $899 | 4.5 |
| Google Pixel 8 | Smartphone | $699 | 4.6 |
Streaming State
Active generation indicator
Generating Report
Generating...
Q4 Report\n\nAnalyzing quarterly data across all departments...
Inline Variant
Compact preview for embedded use
const greeting = "Hello, World!"
console.log(greeting)Props
AIResultPreview component API reference
| Prop | Type | Default | Description |
|---|---|---|---|
content* | string | — | The raw content to preview |
type | 'markdown' | 'code' | 'html' | 'table' | 'image' | 'markdown' | Type of content |
title | string | — | Preview title |
language | string | — | Language label for code previews |
showToggle | boolean | true | Show raw/preview toggle |
streaming | boolean | false | Show streaming indicator |
variant | 'card' | 'inline' | 'fullscreen' | 'card' | Display variant |
onCopy | () => void | — | Callback when content is copied |
onDownload | () => void | — | Callback for download action |
onRegenerate | () => void | — | Callback for regeneration |
Usage
Import and implementation example
import { AIResultPreview } from '@/blocks/ai-conversation/ai-result-preview'
<AIResultPreview type="markdown" title="Generated Report" content={generatedMarkdown} streaming={isGenerating} onRegenerate={() => regenerate()} onDownload={() => downloadAsPDF()}/>Built With
2 componentsThis block uses the following UI components from the design system:
Features
Built-in functionality
- Five content types: Markdown, code, HTML, table, and image preview modes
- Raw/preview toggle: Switch between rendered preview and raw source
- Streaming indicator: Animated indicator during active generation
- Copy to clipboard: One-click content copying with confirmation
- Fullscreen mode: Expand preview to fill viewport
- Auto table parsing: Pipe-delimited text auto-parsed into tables
Accessibility
Accessibility considerations
ARIA Attributes
Content type conveyed through icon and labelKeyboard Navigation
| Key | Action |
|---|---|
| Tab | Navigate between toolbar actions |
| Enter / Space | Toggle view mode and activate buttons |
Notes
- Preview/Raw toggle uses clear text labels
- Copy confirmation shown visually and through icon change