Skip to content

AI Elements

Patterns for conversations with an agent, built from the Silkware components and copied into your project.

AI Elements are the official shadcn patterns for agentic interfaces: the thread, the field, the steps an agent takes, the tools it calls and the places where a person approves or stops it. In Silkware they are not a package. Each pattern is a composition of components you already have, copied into components/ai-elements/<name>.tsx, and you edit the file.

Each pattern is built on Trace, Message, Bubble, Code Block and the other components in this system, so it takes the same tokens, focus rings and dark mode. Install one with its registry item, @silkware/ai-<name>, which brings the components it needs. There is no extra package to depend on, apart from the AI SDK (ai and @ai-sdk/react) and @shadcn/helpers for the patterns that read its messages, and streamdown for the two that render Markdown.

How they fit together

An agent conversation has a few parts, and each pattern covers one of them.

  • The thread is a list of turns. Chat holds it and keeps the reader's place while a reply streams. Message is one turn, with its actions.
  • The field is where the person writes. Prompt Input takes text and files, Model Selector picks the model and Suggestion offers ready-made prompts.
  • The working is what the agent does before it answers. Reasoning, Chain of Thought and Tool show it as steps in a Trace, above the reply.
  • The evidence is what the answer rests on. Sources and Inline Citation let the person check it.
  • The control is how the person stays in charge. Confirmation asks before an action, Checkpoint lets the person go back, and Context shows how much room is left.

Every pattern follows the same rule: the person can see what the agent is doing, stop it, approve what matters and undo what they can.

Patterns

PatternWhat it does
ChatThe thread of a conversation, with a scroller that keeps the reader's place.
MessageOne turn, with copy, rating and retry actions.
Prompt InputThe field with attachments, model and effort choices, and send.
Model SelectorA menu for choosing the model, grouped by provider.
SuggestionReady-made prompts the person sends with one press.
ReasoningThe agent's thinking, open while it thinks and closed when done.
Chain of ThoughtThe agent's steps as one summary that opens into each result.
SourcesThe pages and documents the agent used, under its answer.
Inline CitationA source chip inside a sentence, with the page on hover.
ContextHow much of the context window is used.
CheckpointA point in the thread the person can return to.
PlanThe steps the agent intends to take, before it acts.
QueueMessages and tasks waiting for the agent.
TaskOne unit of work, with its progress and files.
ToolA tool call with its input, output and state.
ConfirmationA request for the person to approve or deny an action.
SubagentWork the agent hands to another agent, with its own steps.
TerminalCommand output from the agent's shell.
Test ResultsThe outcome of a test run, by suite.
Stack TraceAn error with its frames, for the person to read.
File TreeThe files the agent can see or has changed.

Running without a model

Every demo on these pages runs offline. lib/ai.ts re-exports createChat from @shadcn/helpers/ai-sdk, which scripts a conversation and streams it through the real useChat, so the patterns behave as they will with a model. The demos change nothing and call no service. Each page shows the AI SDK code that replaces the script.

Differences from upstream

The patterns are copied from the official shadcn pages with three recorded deviations:

  • Chat has no slide-up animation on the person's message. Upstream uses motion/react for it; this system adds no animation library, so the message renders in a plain MessageScrollerItem.
  • Message renders the reply through components/markdown.tsx, which this system added together with the streamdown package, because the upstream pattern expects it. The file uses isDisabled on the copy button, the React Aria name for upstream's disabled.
  • Model Selector has a plain attach button. Upstream makes it a submit button that is disabled while there is text to send.

Everything else is the upstream code with its comments removed and Prettier formatting applied.