Skip to content
Uxelith
Prov1.0.0AI & Agents

Artifact Canvas

The workspace beside an AI chat: what the model writes opens next to the conversation, streams in line by line, keeps every version and shows what changed down to the word. Preview, read, ask about code, download.

Installs with Uxelith ProHow
Licence
Pro
Packages
2
Updated
11 Nov 2026
Live

Installation

Usage

example.tsx
"use client"

import * as React from "react"

import { ArtifactCanvas, ArtifactCard, type Artifact } from "@/components/artifact-canvas"

const FIRST = `<div class="card">
  <h3>Team</h3>
  <p>$24 / month</p>
  <button>Start free trial</button>
</div>`

export function Workspace() {
  const [artifacts, setArtifacts] = React.useState<Artifact[]>([
    { id: "card", title: "Team plan card", kind: "html", versions: [{ id: "v1", content: FIRST, note: "First version" }] },
  ])
  const [active, setActive] = React.useState<string | null>("card")

  // Your model's stream: add a version, grow its content as tokens arrive, then clear `streaming`.
  function revise(next: string, note: string) {
    setArtifacts((all) =>
      all.map((a) => ({ ...a, versions: [...a.versions, { id: `v${a.versions.length + 1}`, content: next, note }] })),
    )
  }

  return (
    <ArtifactCanvas
      artifacts={artifacts}
      active={active}
      onActiveChange={setActive}
      onAsk={(selection) => console.log("ask about", selection.text)}
      onRestore={(id, versionId) => {
        const old = artifacts[0].versions.find((v) => v.id === versionId)
        if (old) revise(old.content, "Restored")
      }}
    >
      <div className="p-6">
        <p className="mb-3 text-sm">Here is a first version of the card.</p>
        <ArtifactCard artifact={artifacts[0]} current={active === "card"} onClick={() => setActive("card")} />
        <button type="button" className="mt-4 text-sm underline" onClick={() => revise(FIRST.replace("<button>", "<button style=\"background:#f2602a;color:#fff\">"), "Orange button")}>
          Make the button orange
        </button>
      </div>
    </ArtifactCanvas>
  )
}

Props

PropTypeDefaultDescription
childrenReactNode—The conversation, shown beside the canvas. Put an ArtifactCard in a message to open its artifact.
artifactsArtifact[]—Each has id, title, kind ("html", "code" or "markdown"), optional language for code, versions (oldest first: id, content, optional note and at) and streaming while the newest version is still being written.
active / defaultActivestring | nullnullThe open artifact, kept by you or by the component. null closes the canvas.
onActiveChange(id) => void—Called when an artifact opens or the canvas closes.
onAsk(selection) => void—Called with the selected lines (text, startLine, endLine, artifactId, versionId) when someone chooses Ask about this. Without it the button never shows.
onRestore(artifactId, versionId) => void—Called when someone restores an older version: add it again as the newest. Without it there is no Restore button.
previewSandboxstring""Extra sandbox permissions for the HTML preview, which runs with none by default. Never pair allow-scripts with allow-same-origin.
previewHeadstring""Markup put before every HTML preview, e.g. a <style> with your base styles.
defaultSplitnumber0.42Share of the width the conversation takes at first, 0.28 to 0.68. The divider can be dragged or moved with the arrow keys.
labelstring"Canvas"Accessible name of the canvas.

Accessibility

  • The canvas is a labelled region; when it opens, focus moves to its title, and when it closes, focus goes back to whatever opened it. Escape closes it.
  • Preview, Code and Changes are tabs: Left and Right move between them.
  • The divider is a separator with its value: Left and Right resize, Home and End jump to the limits.
  • Changes say "added" and "removed" to screen readers, not only in colour.
  • Writing and each new version are announced through a polite live region.
  • The version list is a menu: Up, Down, Home and End move, Enter picks, Escape closes it.
  • HTML previews run in a sandboxed frame with no permissions unless you add them.
  • Under prefers-reduced-motion nothing slides, pulses or blinks.

Changelog

  1. v1.0.0Latest

    First release.

More in AI & Agents

All 9 in AI & Agents
  • AI & AgentsPro

    Agent Run Monitor

    A live view of AI agents working together: each agent's steps on one timeline, cost against a budget, tokens, every step's input and output, failures, and an approval card when a step needs a person.

  • AI & AgentsPro

    Approval Card

    The moment an AI agent asks before acting: what it wants to do, why, and exactly what will happen. Approve is held for a beat so it's never an accident; Deny is one press. Then it folds into a one-line record.

  • AI & AgentsPro

    Diff Review

    Review an AI agent's code changes: accept or reject each one, see exactly which words changed, comment on a line and ask the agent to revise, then apply only what you accepted. Unified or side by side.