Skip to content
Get startedMigrating from AI ElementsMenu

Migrating from AI Elements

Every AI Elements component and its chatcn counterpart, including the workspace pieces that have no shadcn replacement.

AI Elements is deprecated. Most of it maps one to one onto chatcn, and the pieces with no shadcn replacement (Artifact, WebPreview, JSXPreview) ship here as Artifact, Artifact panel, Web preview and JSX preview. Names below come from the AI Elements source on GitHub.

How the APIs differ

  • Plain props over parts. AI Elements composes many small parts (WebPreviewNavigation, WebPreviewUrl, WebPreviewBody). chatcn components take props and render the whole pattern, with slots such as actions for what you add.
  • Message parts in, components out. chatcn reads AI SDK UIMessage parts directly; helpers like toolCallPropsFromPart map a part to props.
  • One adapter for the runtime. Wire useChat once with useChatcnChat and pass actions down, instead of threading callbacks through each component.
  • Files install under `components/ui/chatcn/`, so they never overwrite your shadcn components and both can live side by side while you migrate.

Component map

AI ElementschatcnNotes
Artifact, ArtifactHeader, ArtifactTitle, ArtifactDescription, ArtifactActions, ArtifactAction, ArtifactClose, ArtifactContentArtifact, Artifact panelThe card in the message and the panel are separate. ArtifactPanel has the header, actions, versions and Code/Preview built in; extra actions go in actions with ArtifactPanelAction
WebPreview, WebPreviewNavigation, WebPreviewNavigationButton, WebPreviewUrl, WebPreviewBody, WebPreviewConsoleWeb previewOne component. defaultUrl and onUrlChange carry over; history, devices, loading and crash view are built in; console messages go in logs
JSXPreview, JSXPreviewContent, JSXPreviewError, useJSXPreviewJSX previewjsx, components, bindings and onError carry over, isStreaming becomes streaming, the error part becomes renderError. No react-jsx-parser dependency and nothing is evaluated
Conversation, ConversationContent, ConversationScrollButton, ConversationEmptyState, ConversationDownloadconversation, scroll-to-bottom, empty-stateStick to bottom is built into conversation
Message, MessageContent, MessageResponsemessage, markdownMessageResponse becomes markdown, which streams without layout shift
MessageActions, MessageAction, MessageToolbarmessage-actions
MessageBranch, MessageBranchContent, MessageBranchSelector, MessageBranchPrevious, MessageBranchNext, MessageBranchPagebranch-navigator
PromptInput and its partsprompt-input, attachment, model-picker, send-buttonIME safe Enter and Send to Stop in the same footprint are built in
Attachments, Attachment, AttachmentPreview, AttachmentRemoveattachment
ModelSelector and its partsmodel-picker
SpeechInputdictation-button
Reasoning, ReasoningTrigger, ReasoningContentreasoning
ChainOfThought and its partstrace, trace-group
Tool, ToolHeader, ToolContent, ToolInput, ToolOutputTool callPass a part with toolCallPropsFromPart
Confirmation and its partsTool callApproval is built into the tool call: allow once, always allow, or deny with a note
Sources, SourcesTrigger, SourcesContent, Sourcesources
InlineCitation and its partscitation
CodeBlock and its partscode-block
Snippetinline-code
Suggestions, Suggestionsuggestions
Shimmershimmer-textThe only shimmer chatcn allows, for status labels
Checkpointcheckpoint
Imageimage
Terminal and its partsterminal
StackTrace and its partsstack-trace
TestResults and its partstest-results
FileTree and its partsfile-tree
EnvironmentVariables and its partsenvironment-variables
Commit and its partscommit-card
Sandbox and its partssandbox
Plan, Task, QueuePlan, Task, Queued messagesSteps with live status, expandable tasks, and messages queued while the agent works
Context and its partsContext meterA ring in the composer footer with a usage breakdown on open
Agent and its partsAgent cardModel, tools and instructions at a glance
Canvas, Node, Edge, Connection, Controls, Panel, ToolbarWorkflow, CanvasWorkflow draws the agent graph; Canvas is the side by side document editor
QuestionQuestionnaireOne or several questions the agent asks before it continues
Persona, AudioPlayer, Transcription, MicSelector, VoiceSelectorVoice orb, Audio player, Transcript, Voice controls, Voice pickerMicrophone selection lives in Voice controls; a full call is Voice session
OpenIn, PackageInfo, SchemaDisplayNot includedUse JSON viewer for schemas; the others are small enough to keep from AI Elements

Wire up useChat

tsx
import { DefaultChatTransport } from "ai"
import { useChatcnChat } from "@/hooks/use-chatcn-chat"

const { chatcnMessages, actions } = useChatcnChat({
  transport: new DefaultChatTransport({ api: "/api/chat" }),
})

Your /api/chat route stays as it is. See the AI SDK adapter for the action map and a mock transport for demos.

Install the workspace pieces

$ pnpm dlx shadcn@latest add https://chatcn.dev/r/artifact-panel.json
$ pnpm dlx shadcn@latest add https://chatcn.dev/r/web-preview.json
$ pnpm dlx shadcn@latest add https://chatcn.dev/r/jsx-preview.json