Side panel for what an AI agent made: Preview and Code tabs, a version switcher with a note per version, copy, and code that streams in while the agent writes.
Set your access key from API keys as NEXTUI_TOKEN in .env.local and add the @nextui namespace below to components.json once. Then every item installs by name. Each install counts as a copy on a free account.
$pnpm dlx shadcn@latest add @nextui/artifact-panel
1{2"registries": {3"@nextui": {4"url": "https://nextui.dev/r/{name}.json",5"headers": { "Authorization": "Bearer ${NEXTUI_TOKEN}" }6}7}8}
1"use client";23import { useState } from "react";4import { ArtifactPanel, type ArtifactVersion } from "@/components/nextui/artifact-panel";56// Keep every version the agent writes; the newest one streams while the agent is busy.7export function Workspace({ versions, writing }: { versions: ArtifactVersion[]; writing: boolean }) {8const [version, setVersion] = useState<number>();910return (11<div className="grid gap-4 lg:grid-cols-[1fr_32rem]">12{/* chat on the left */}13<ArtifactPanel14title="pricing-card.tsx"15kind="Component"16versions={versions}17version={version ?? versions.length - 1}18onVersionChange={setVersion}19streaming={writing}20/>21</div>22);23}
| Prop | Type | Default | Description |
|---|---|---|---|
| title | string | "pricing-card.tsx" | File name or title in the header |
| kind | string | "Component" | Chip next to the title; leave empty to hide it |
| versions | { label?: string; code: string; preview?: ReactNode; note?: string }[] | – | Saved versions, oldest first |
| version | number | – | Controlled version index |
| defaultVersion | number | – | Starting version index; defaults to the newest |
| onVersionChange | (index: number) => void | – | Called when the user steps through versions |
| tab | "preview" | "code" | – | Controlled tab |
| defaultTab | "preview" | "code" | "preview" | Starting tab |
| onTabChange | (tab) => void | – | Called when the user switches tabs |
| streaming | boolean | false | The newest version's code is still arriving; shows a cursor and follows the last line |
| autoPlay | boolean | false | Play a scripted edit on a loop while on screen, for demos |
| className | string | – | Extra classes on the wrapper |
Sign in to see the code
Preview it freely. A free account copies code and prompts a few times a day.