Conversation, Message, Tool, Reasoning, and PromptInput are designed to drop directly into any React project and wire to stream.messages with minimal glue code.
How it works
- Install components as source files: AI Elements ships via a CLI that adds components directly to your project (shadcn/ui registry style)
- Map messages to components: iterate
stream.messages, renderHumanMessageinstances as user bubbles andAIMessageinstances as assistant responses - Compose richer UIs: wrap tool calls in
<Tool>, reasoning in<Reasoning>, and everything in<Conversation>for scroll management
Installation
Install AI Elements components via the CLI. They’re added as editable source files into your project:Wiring useStream
Render AI Elements components directly fromstream.messages. Each LangChain BaseMessage maps to a component:
Best practices
- Edit source files freely: components ship in your project, not as an external package dependency, so you can change anything without forking
- Use
MessageResponsefor streaming: it handles streamed partial tokens correctly; avoid rendering rawmsg.contentdirectly during streaming - Wrap in
Conversation: theConversationcomponent manages scroll behaviour so new messages auto-scroll into view - Gate on
isInstance: useHumanMessage.isInstance(msg)andAIMessage.isInstance(msg)rather than checkingmsg.getType()for proper TypeScript narrowing
Connect these docs to Claude, VSCode, and more via MCP for real-time answers.

