VibeArtifact
VibeArtifact combines the Artifact container from AI Elements SDK with VibeFrame to create a complete component display experience. It includes Run, Copy, Regenerate, Download, Share actions and a Code/Preview toggle—everything users expect when interacting with generated components.Basic Usage
Props
| Prop | Type | Default | Description |
|---|---|---|---|
name | string | required | Component name displayed in header |
code | string | required | React component code |
description | string | - | Optional description |
data | Record<string, unknown> | {} | Data passed to the component |
updatedAt | Date | - | Timestamp for “Updated X ago” |
defaultView | 'preview' | 'code' | 'preview' | Initial view mode |
className | string | - | CSS class for container |
minHeight | number | 150 | Minimum preview height |
maxHeight | number | 500 | Maximum preview height |
onRun | () => void | - | Called when Run is clicked |
onRegenerate | () => void | - | Called when Regenerate is clicked |
onShare | () => void | - | Called when Share is clicked |
Action Buttons
Built-in Actions
| Button | Icon | Behavior |
|---|---|---|
| Run | ▶ | Refreshes the iframe, re-executes component |
| Copy | 📋 | Copies code to clipboard, shows checkmark |
| Regenerate | 🔄 | Calls onRegenerate callback (only shown if provided) |
| Download | ⬇ | Downloads code as {name}.tsx file |
| Share | 📤 | Calls onShare callback (only shown if provided) |
| Code/Preview | 👁/< > | Toggles between preview and code view |
Handling Actions
View Modes
Preview Mode (Default)
Shows the rendered component in a VibeFrame:Code Mode
Shows the raw code with syntax highlighting:Timestamps
Show when the component was last updated:- “just now” (< 1 minute)
- “X minutes ago” (< 1 hour)
- “X hours ago” (< 1 day)
- “X days ago” (< 1 week)
- Full date (> 1 week)
Composition with Artifact Primitives
VibeArtifact is built on the Artifact primitives. For custom layouts, use them directly:Artifact Primitives
Artifact
Main container with border and shadow:ArtifactHeader
Header with title and actions:ArtifactAction
Action button with optional tooltip:ArtifactContent
Scrollable content area:ArtifactClose
Close button (for modal/panel usage):Styling
VibeArtifact uses Tailwind CSS and respects your theme:Example: Full Studio Integration
Next Steps
VibeFrame
Learn about the secure rendering engine
Storage
Persist components to your database