Overview
Panel artifacts are standalone web apps that run inside iframes and communicate with the Artifactuse SDK via postMessage. You can build custom panels using any framework - React, Vue, Svelte, or vanilla JavaScript.Panels Repository
View source code, development docs, and contribution guidelines
Official Panels
| Package | Description | Tier |
|---|---|---|
@artifactuse/json-panel | Interactive JSON tree viewer | 🆓 Free |
@artifactuse/svg-panel | SVG preview with pan/zoom | 🆓 Free |
@artifactuse/diff-panel | Side-by-side diff comparison | 🆓 Free |
@artifactuse/html-panel | HTML + Markdown preview | 🆓 Free |
@artifactuse/react-panel | React/JSX preview | 🆓 Free |
@artifactuse/vue-panel | Vue SFC preview | 🆓 Free |
@artifactuse/form-panel | Interactive forms, wizards | 🆓 Free |
@artifactuse/editor-panel | Canvas + Video editor | ⭐ Pro |
@artifactuse/code-panel | JS + Python code execution | ⭐ Pro |
How Panels Work
- SDK detects artifact type in AI response
- SDK loads appropriate panel URL in iframe
- Panel signals ready via
panel:readymessage - SDK sends artifact data via
load:artifactmessage - Panel renders content and sends events back
Communication Protocol
Panels communicate with the SDK using the standardpostMessage API. All messages use the artifactuse type for identification.
SDK → Panel: Loading Artifacts
When the SDK opens a panel, it sends aload:artifact message containing the full artifact data:
Artifact Code Formats
Thecode field contains different formats depending on the panel type:
| Panel | Language Values | Code Format | Needs JSON Parse |
|---|---|---|---|
json-panel | json | JSON string to display | ✅ Yes |
form-panel | form | JSON form configuration | ✅ Yes |
diff-panel | diff | JSON: {oldCode, newCode, language} | ✅ Yes |
editor-panel | canvas, video | JSON: {width, height, shapes} | ✅ Yes |
svg-panel | svg | Raw SVG markup | ❌ No |
html-panel | html, markdown, md | Raw HTML/Markdown | ❌ No |
react-panel | react, jsx | Raw JSX code | ❌ No |
vue-panel | vue | Raw Vue SFC code | ❌ No |
code-panel | javascript, js, python, py | Raw code | ❌ No |
SDK → Panel: Theme Updates
The SDK sends theme updates when the user changes themes:Panel → SDK
Building a Custom Panel
Vanilla JavaScript
Using the Bridge Helper
For convenience, use@artifactuse/shared which handles the message protocol:
- Vue
- React
- Svelte
JSON Sanitization
When parsingartifact.code that contains JSON, you may encounter unescaped newlines inside string values. This happens when the code extractor doesn’t properly escape literal newlines.
Always sanitize before parsing:
json-panel- displays JSON dataform-panel- parses form configurationdiff-panel- parses{oldCode, newCode}structureeditor-panel- parses canvas/video data
svg-panel- raw SVG markuphtml-panel- raw HTML/Markdownreact-panel- raw JSX codevue-panel- raw Vue SFC codecode-panel- raw JavaScript/Python
Theme Support
Panels should support both dark and light themes. The SDK sends theme updates viatheme:change message.
CSS Variables
Use CSS variables for easy theming:Registering Custom Panels
The SDK supports configurable panels that can be added, overridden, or disabled without modifying SDK source code.Configuration Options
Panel Configuration Formats
| Format | Example | Description |
|---|---|---|
| Relative path | 'chart-panel' | Uses cdnUrl as base |
| Full URL | 'https://cdn.example.com/panel' | Direct URL to panel |
| Object | { path: 'panel', cdn: 'https://...' } | Explicit path + CDN |
| Null | null | Disable the panel |
Runtime Registration
Register panels at runtime with support for type aliases:- Vue
- React
- Svelte
- Vanilla JS
How Panel Routing Works
When the SDK detects an artifact, it looks up the panel URL using:- Artifact type (e.g.,
form,social) - Code language (e.g.,
json,svg,python)
Full Example
Default Panels
The SDK includes these built-in panel mappings:| Type/Language | Panel Path |
|---|---|
form | form-panel |
video, videoeditor, timeline | editor-panel/video |
canvas, whiteboard, drawing | editor-panel/canvas |
json | json-panel |
svg | svg-panel |
diff, patch | diff-panel |
javascript, js, python, py | code-panel |
jsx, react | react-panel |
vue | vue-panel |
html, htm, markdown, md | html-panel |
mermaid | mermaid-panel |