AI Elements
Introduction
AI Elements are the parts of a chat or agent interface. They are the shadcn AI components and patterns with Formance styling. The props and exports are the same as upstream, so the shadcn documentation applies to them too.
They follow the AI SDK message model, but the components do not depend on it. The demos script their conversations with @shadcn/helpers, so they run without a model or an API key.
Components#
These are in the Components section. Install them from the registry, for example npx shadcn@latest add @formance/trace.
- Message Scroller holds the conversation and keeps the latest turn in view.
- Message is one row, with an avatar, a header, and a footer.
- Bubble is the surface of the text in a message.
- Marker shows a status between messages: thinking, an applied edit, or a date.
- Attachment shows a file that the user or the agent adds to the conversation.
- Trace is a list of agent steps. Most patterns are built on it.
- Code Block shows code, terminal output, and diffs, with the Formance code theme.
- Questionnaire asks the user a sequence of questions, for example to clarify a request.
Patterns#
A pattern is a composition of the components above. There is nothing more to install: copy the code of the demo into your project.
- The thread: Chat, Message, Prompt Input, Suggestion, Model Selector, Context, Checkpoint.
- The steps of the agent: Reasoning, Chain of Thought, Plan, Task, Queue, Subagent.
- Tools and their output: Tool, Confirmation, Terminal, Stack Trace, Test Results, File Tree.
- Sources: Sources, Inline Citation.