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
| Pattern | What it does |
|---|---|
| Chat | The thread of a conversation, with a scroller that keeps the reader's place. |
| Message | One turn, with copy, rating and retry actions. |
| Prompt Input | The field with attachments, model and effort choices, and send. |
| Model Selector | A menu for choosing the model, grouped by provider. |
| Suggestion | Ready-made prompts the person sends with one press. |
| Reasoning | The agent's thinking, open while it thinks and closed when done. |
| Chain of Thought | The agent's steps as one summary that opens into each result. |
| Sources | The pages and documents the agent used, under its answer. |
| Inline Citation | A source chip inside a sentence, with the page on hover. |
| Context | How much of the context window is used. |
| Checkpoint | A point in the thread the person can return to. |
| Plan | The steps the agent intends to take, before it acts. |
| Queue | Messages and tasks waiting for the agent. |
| Task | One unit of work, with its progress and files. |
| Tool | A tool call with its input, output and state. |
| Confirmation | A request for the person to approve or deny an action. |
| Subagent | Work the agent hands to another agent, with its own steps. |
| Terminal | Command output from the agent's shell. |
| Test Results | The outcome of a test run, by suite. |
| Stack Trace | An error with its frames, for the person to read. |
| File Tree | The 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/reactfor it; this system adds no animation library, so the message renders in a plainMessageScrollerItem. - Message renders the reply through
components/markdown.tsx, which this system added together with thestreamdownpackage, because the upstream pattern expects it. The file usesisDisabledon the copy button, the React Aria name for upstream'sdisabled. - 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.