Artifact preview preview

Artifact preview

The pane beside an AI chat that shows the HTML page the model is writing: a live, scriptless draft while it streams, then sandboxed versions that swap in without a flash, with a version stepper, desktop / tablet / phone widths, and copy, download and open.

  • Group
    Chat
  • Origin
    Adapted · fx0 (Vercel) · source
  • License
    Apache-2.0
  • Added
    Oct 23
npx shadcn@latest add @deank/artifact-preview

The registry stays private. Install from the repo with a GitHub token — see the README.

Usage

import { ArtifactPreview } from "@/registry/components/artifact-preview/artifact-preview";

<ArtifactPreview versions={[/* … */]} />

Props

PropTypeDefaultDescription
versionsArtifactVersion[]Finished versions, oldest first. The newest is shown unless the user steps back.
draft?string | nullnullThe page as the model is writing it. Shown over the latest version while set; pass null when it is done.
title?stringName of the artifact; also the download file name ("Pricing page" → pricing-page.html).
defaultViewport?ArtifactViewport"desktop"Start on this width.
allowScripts?booleantrueLet finished versions run their scripts (still sandboxed, never same-origin).
hideActions?booleanfalseHide copy, download and open.
empty?ReactNodeShown when there is no version and no draft yet.
onVersionChange?(index: number) => voidCalled with the version index the user steps to.
className?string

When to use

AI or agent products that generate HTML, emails, landing pages, slides or reports: show the result next to the chat while it streams, and let people step back through versions and take the file.

When not to use

Previewing a React component inside your own app (render it directly); untrusted HTML you need to run with same-origin access (never; keep it sandboxed); code with syntax highlighting (code-block).

Related

Tool call card · Message actions · Inline citation · Code block · Prompt input