Artifact Preview

Framed preview for AI generated artifacts such as code, documents or UI, with a title bar, copy button and optional expand action for a full view.

src/registry/ui/artifact-preview.tsx/r/artifact-preview.json

preview.tsx

const ok = true

Artifact

Installation#

bash
npx shadcn@latest add @minidev/artifact-preview

MiniDev UI is in the shadcn registry directory, so the short form works with no setup. Older CLI versions can use the full URL: npx shadcn@latest add https://ui.minidev.pro/r/artifact-preview.json

Usage#

tsx
import { ArtifactPreview } from "@/components/ui/artifact-preview"

export function Example() {
  return (
    <ArtifactPreview title="preview.tsx" copyValue=" console.log(1)">{" "}<pre className="font-mono text-xs text-fg">const ok = true</pre></ArtifactPreview>
  )
}

API reference#

ArtifactPreview props
PropTypeDefault
title*string-
children*React.ReactNode-
classNamestring-
copyValuestring-
onExpand() => void-

* required

Dependencies#

npm

lucide-react
All AI chat UI components for React