Skip to content
Latestv1.0.63

AiArtifacts ​

AiArtifacts is an immersive side rendering panel designed to display complex AI-generated content, such as HTML pages, UI prototypes, large code modules, or interactive ECharts charts.

Basic Usage ​

Control visibility via v-model:visible and pass artifact details through the data prop.

Basic Usage

Multi-version Support ​

Artifacts allow users to switch between different iterations. Use the versions array to provide history and the version-change event to monitor user selection. You can use slots to customize the rendering of specific versions.

Version Switching

Rendering Modes ​

Supports preview (live rendering) and code (syntax highlighting) modes. Default mode is preview for HTML content.

Source Mode

Inline Display Mode ​

By setting mode="inline", the component will appear as a standard block element embedded in the page stream or chat bubbles.

Inline Mode & Theme Overrides

ECharts Interactive Chart - Line Chart ​

When data.type is set to 'echarts', the component automatically loads ECharts and renders an interactive chart. Pass the chart type and ECharts configuration via echartsOption. Supports data zoom (dataZoom), toolbox (toolbox), and chart events like chart-ready and chart-click.

Line Chart - Monthly Sales Trend

ECharts Interactive Chart - Bar Chart ​

Bar charts are ideal for multi-dimensional category comparisons. Set echartsOption.chartType to 'bar'. Use @chart-error to catch chart loading failures.

Bar Chart - Quarterly Product Comparison

ECharts Interactive Chart - Pie Chart ​

Donut pie charts are ideal for showing proportional relationships. Set chartType to 'pie' and configure inner/outer radius via series[].radius.

Pie Chart - Market Share Analysis

ECharts Interactive Chart - Radar Chart ​

Radar charts are perfect for multi-dimensional competency or KPI assessments. Set chartType to 'radar' and define your indicators in radar.indicator.

Radar Chart - Competency Assessment

Multimedia and File Preview ​

The component supports quick previews of images, videos, audios, PDFs, plain text, and Iframe webpages, automatically matching the rendering and control behaviors based on type.

Multimedia and File Preview

Dynamic Vue SFC Compilation Preview ​

When data.type is set to 'vue' and no custom #vue slot is defined by the host application, the component dynamically compiles and renders the Vue Single File Component (SFC) code inside a sandboxed iframe using the local built-in compiler and packages (such as vue3-sfc-loader and yh-ui-bundle.js).

This significantly simplifies previewing AI-generated components in a secure, style-isolated sandboxed environment.

Dynamic Vue SFC Previews

API ​

Props ​

PropertyDescriptionTypeDefault
visibleWhether visible (supports v-model:visible)booleanfalse
dataArtifact data structureArtifactData—
widthPanel widthstring | number'50%'
fullscreenWhether fullscreenbooleanfalse
modeRendering mode'preview' | 'code' | 'inline''preview'
theme-overridesTheme variable overridesComponentThemeVars—
echarts-optionECharts chart options (for chart/echarts type)ArtifactEChartsOption—
auto-load-e-chartsAuto load ECharts librarybooleantrue
echarts-themeECharts theme'light' | 'dark' | 'default''light'
echarts-data-zoomEnable data zoombooleantrue
echarts-toolboxShow toolboxbooleantrue
chart-heightChart heightstring | number400
responsive-widthWhether width is responsivebooleantrue
chart-loading-textPlaceholder text while chart is loadingstring'加载图表中...'
sandbox-yh-ui-urlyh-ui bundle URL used by the Vue SFC sandbox renderer. When not set, loads the published version from CDN (esm.sh). Docs override globally via provide('yhSandboxYhUiUrl', ...).stringCDN auto
sandbox-yh-ui-css-urlyh-ui CSS URL used by the Vue SFC sandbox rendererstringCDN auto

ArtifactData ​

PropertyDescriptionType
idUnique IDstring
titleTitle / Filenamestring
typeContent type'code' | 'html' | 'markdown' | 'vue' | 'react' | 'diagram' | 'chart' | 'sandbox' | 'canvas' | 'echarts' | 'image' | 'video' | 'audio' | 'pdf' | 'text' | 'iframe'
currentVersionCurrently selected version labelstring | number
versionsVersion listArtifactVersion[]
echartsOptionECharts options (for chart/echarts types)ArtifactEChartsOption

ArtifactVersion ​

PropertyDescriptionType
versionVersion labelstring | number
contentSource code/contentstring
descriptionChanges descriptionstring
timestampVersion timestampstring | number

ArtifactEChartsOption ​

PropertyDescriptionTypeDefault
chartTypeChart type'line' | 'bar' | 'pie' | 'scatter' | 'gauge' | 'radar' | 'funnel' | 'treemap' | 'sunburst' | 'heatmap' | 'candlestick' | 'boxplot' | 'sankey' | 'themeRiver' | 'graph' | 'custom'—
optionStandard ECharts option objectRecord<string, unknown>—
themeChart theme (overrides global)'light' | 'dark' | 'default'—
dataZoomEnable data zoomboolean—
toolboxShow toolboxboolean—
interactiveEnable interactions (click, hover)boolean—

Events ​

NameDescriptionParameters
update:visibleEmitted when visibility changes(val: boolean) => void
update:modeEmitted when mode switches(mode: string) => void
version-changeTriggered when switching version(v: ArtifactVersion) => void
chart-readyECharts instance initialized(chart: unknown) => void
chart-clickTriggered when clicking a data point(params: unknown) => void
chart-errorTriggered when chart fails to load(error: Error) => void
closeEmitted when closing the panel—

Slots ​

NameDescriptionScope
chartCustom chart render area (type='chart'){ data: ArtifactVersion | null, title: string }
canvasCustom canvas render area (type='canvas'){ data: ArtifactVersion | null }

Use in Nuxt ​

This component fully supports Nuxt 3/4. In Nuxt projects, the component will be automatically imported. Since ECharts is loaded via dynamic import (lazy loading), it is SSR-friendly with no extra configuration needed.

For manual registration, see the Nuxt Integration guide.

Theme Variables ​

Variable NameDescriptionDefault Value
--yh-ai-artifacts-bg-colorPanel background colorvar(--yh-bg-color-overlay)
--yh-ai-artifacts-header-heightHeader height56px
--yh-ai-artifacts-border-colorDivider colorvar(--yh-border-color-lighter)
--yh-ai-artifacts-shadowPanel shadowvar(--yh-box-shadow-light)

Released under the MIT License.