Skip to main content
The main component for rendering AI-generated content. Automatically detects and renders artifacts including code blocks, forms, social previews, images, videos, and more.

Import

Usage

Props

Events

Event names use kebab-case in Vue (@form-submit) and camelCase in React (onFormSubmit). Svelte uses kebab-case with on: prefix (on:form-submit).

Artifact Rendering

The component automatically renders different artifact types:

Inline Code Preview

By default, code artifacts render as clickable cards. Enable inlinePreview in your SDK config to show truncated syntax-highlighted code previews directly in the message:
Clicking a truncated preview opens the full artifact in the panel. Languages not listed still render as cards.
Inline code preview requires Prism.js for syntax highlighting. Load Prism and language grammars via CDN or npm.

Exclude Languages

When using languages: true, exclude specific languages from inline preview with excludeLanguages. Excluded languages fall back to artifact cards:
This is only meaningful when languages: true. When languages is an array, simply omit the language from the array instead.

Non-Clickable Short Code

When code is shorter than maxLines, the full code is visible — clicking opens a panel that shows the same content. Use minClickableLines to disable clicking for these short blocks:
For languages where the panel adds value (e.g., HTML renders a live preview), use ignoreLanguages to keep them clickable:

Custom Action Labels

Customize the fade overlay label text per language:
String shorthand applies to all languages:
The (N lines) suffix is always appended automatically (e.g., “Open preview (24 lines)”).

Inline Code

To show full syntax-highlighted code directly in the message without extraction or panel, enable inlineCode:
Code blocks for listed languages stay as normal <pre><code> blocks with Prism.js syntax highlighting. No artifact card, no panel, no extraction.
When a language matches both inlineCode and inlinePreview, inlineCode takes priority (no extraction).

Tabs & View Mode

Control which panel tabs are visible and the initial view mode, globally or per-message:
Available tabs: 'preview', 'code', 'split', 'edit'. Available view modes match the tab names.

Config Precedence

All options support both global config and component prop levels. Precedence: Component prop → Global config → Default

Form Collapse Behavior

Inline forms automatically collapse after user interaction to prevent duplicate submissions and keep the chat clean.

Form States

Behavior Rules

  • Current session: Forms stay active until user interacts
  • After submit/cancel/custom action: Form collapses immediately
  • After page refresh:
    • Last message forms stay active (via isLastMessage prop)
    • Older message forms collapse as inactive
  • Reset action: Form stays active (doesn’t collapse)

Example with isLastMessage

Media Lightbox

Images and PDFs automatically open in a fullscreen lightbox viewer when clicked. The viewer supports:
  • Zoom - Click image or zoom button to toggle zoom
  • Download - Download the original file
  • Keyboard - Press Escape to close
  • Click outside - Click overlay to close

Typing Indicator

Show a typing indicator while streaming AI responses:
The typing indicator displays animated loading bars that disappear when typing becomes false.

Example: Full Integration