Skip to content

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.

Tip: Click v1/v2 at the top of the side panel to experience version switching.
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.

Dashboard Preview
Versions
v1
v2
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

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'加载图表中...'

ArtifactData

PropertyDescriptionType
idUnique IDstring
titleTitle / Filenamestring
typeContent type'code' | 'html' | 'markdown' | 'vue' | 'react' | 'diagram' | 'chart' | 'sandbox' | 'canvas' | 'echarts'
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.