Skip to content
WebJs
Menu

AI Elements

Patterns for agentic interfaces, built from WebJs UI components.

AI Elements are patterns for building agentic interfaces. Each one is a composition of WebJs UI components that you copy into your project. The code is yours.

A Chat is a list of Message turns inside a Message Scroller. The steps an agent takes inside a turn, like Reasoning, Tool and Plan, are built on Trace, so every step has the same shape.

Building a chatbot? Start from the Chat pattern. It puts Message Scroller, Message and Prompt Input together, and the AI SDK page shows how a 'use server' action streams the reply into it, with tool calls and reasoning as parts.

Coming from elements.ai-sdk.dev? See Migrating from AI SDK Elements.

Patterns

Migrating from AI SDK Elements

If you used AI SDK Elements from elements.ai-sdk.dev, here is what changes.

Existing projects

When you installed components from elements.ai-sdk.dev, the code was copied into your project under components/ai-elements. In a WebJs app each of them is a pattern built from WebJs UI components, so moving to WebJs means rebuilding each one on those components.

Each pattern page has a Migrating from AI SDK Elements section that maps every export of the wrapper in components/ai-elements onto the parts of the pattern, so you can rebuild it on Trace, Code Block and the other WebJs UI components one export at a time.

For example, the Queue section rebuilds queue.tsx on Trace, and the Inline Citation section rebuilds inline-citation.tsx on Hover Card.

What replaces each element

Each file from AI SDK Elements, and the WebJs UI pattern or component that replaces it.

AI SDK ElementsWebJs UI
agent.tsxSubagent
attachments.tsxAttachment
chain-of-thought.tsxChain of Thought
checkpoint.tsxCheckpoint
code-block.tsxCode Block
commit.tsxTrace
confirmation.tsxConfirmation
context.tsxContext
conversation.tsxChat
file-tree.tsxFile Tree
inline-citation.tsxInline Citation
message.tsxMessage
model-selector.tsxModel Selector
plan.tsxPlan
prompt-input.tsxPrompt Input
question.tsxQuestionnaire
queue.tsxQueue
reasoning.tsxReasoning
shimmer.tsxshimmer
sources.tsxSources
stack-trace.tsxStack Trace
suggestion.tsxSuggestion
task.tsxTask
terminal.tsxTerminal
test-results.tsxTest Results
tool.tsxTool

Elements without a replacement

Each of these elements is a small composition you can build from components WebJs UI already has, listed below.

If you need one of these, open an issue and we will help you build it.

AI SDK ElementsBuild it with
artifact.tsxCard, Button and Tooltip
audio-player.tsxAn audio element, with Button Group and Slider
canvas.tsx, connection.tsx, controls.tsx, edge.tsx, node.tsx, panel.tsx and toolbar.tsxA graph library that renders to the DOM, with Card and Button Group
environment-variables.tsxItem, Badge and Switch
image.tsxAn img element
jsx-preview.tsxNot needed: WebJs templates are html tagged templates, not JSX
mic-selector.tsx and voice-selector.tsxCombobox
open-in-chat.tsxDropdown Menu
package-info.tsxItem and Badge
persona.tsxA Rive animation
sandbox.tsxTrace, Tabs and Code Block
schema-display.tsxCollapsible, Badge and Code Block
snippet.tsxInput Group
speech-input.tsxButton and Spinner, with the Web Speech API
transcription.tsxA Button for each segment, to seek to it
web-preview.tsxAn iframe, with Input Group for the address bar

New projects

Build from WebJs UI components instead.

Add the components

pnpm dlx @webjsdev/ui add trace code-block

Copy a pattern

Open a pattern above and copy its code into your project. Each page lists any other components it needs.

Or ask your coding agent to do it:

Prompt
Add the Reasoning pattern from https://webjs.dev/ui/llm/docs/ai-elements/reasoning to my chat.

Need another element? Open an issue and tell us what you need.