Thinking UI

Artifact CardPRO

An inline card for a generated artifact that morphs open into a preview panel.

Code

2 files · 299 lines of TypeScriptPRO

Artifact Card is part of Pro

Get its source, the one-paste agent prompt and all 113 components, for a one-time $99.

Motion notes

  • The card and the panel share layoutIds for the shell, icon and title. One unmounts and the other grows out of its box, so opening reads as the same object getting bigger, not a new window.
  • Inner rows opt into layout so Motion counter-scales them during the morph, and the preview body fades in only once the shell is most of the way there. Nothing is ever seen stretched.
  • The corner radius is read from the --radius-card token as pixels, because Motion can only keep corners round mid-morph when it knows the radius in px.
  • While streaming, the meta line shimmers and a thin light runs along the bottom edge. The version chip pops in when it finishes. With reduced motion the card and panel cross-fade in place.

Usage

Example
<ArtifactCard
    title="Pricing page"
    kind="app"
    status={done ? "ready" : "generating"}
    version={2}
    description="React · 142 lines"
    panelClassName="h-72"
  >
    <iframe srcDoc={html} className="size-full" />
  </ArtifactCard>

Props

PropTypeDefaultDescription
titlestring—Artifact name, e.g. “Pricing page”.
kind"document" | "code" | "app""document"Picks the type icon and the default meta label.
status"generating" | "ready""ready"Shows a shimmering “Generating…” while the artifact streams in.
versionnumber—Shown as a chip (v2) once ready. Changing it re-pops the chip.
descriptionstring—Meta line once ready, e.g. “React · 142 lines”. Defaults to the kind's label.
childrenReactNode—The preview rendered in the expanded panel.
openboolean—Controlled expanded state.
defaultOpenbooleanfalseInitial expanded state when uncontrolled.
onOpenChange(open: boolean) => void—Called when the user opens or collapses the card. Escape collapses.
panelClassNamestring—Classes for the panel body, e.g. a height.
classNamestring—Classes for the wrapper.