Skip to main content
AI Elements is a composable, shadcn/ui-based component library purpose-built for AI chat interfaces. Components like Conversation, Message, Tool, Reasoning, and PromptInput are designed to drop directly into any React project and wire to stream.messages with minimal glue code.
Clone and run the full AI Elements example to see tool call rendering, reasoning display, streaming messages, and more in a working project.

How it works

  1. Install components as source files: AI Elements ships via a CLI that adds components directly to your project (shadcn/ui registry style)
  2. Map messages to components: iterate stream.messages, render HumanMessage instances as user bubbles and AIMessage instances as assistant responses
  3. 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 from stream.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 MessageResponse for streaming: it handles streamed partial tokens correctly; avoid rendering raw message content directly during streaming
  • Wrap in Conversation: the Conversation component manages scroll behaviour so new messages auto-scroll into view
  • Gate on isInstance: use HumanMessage.isInstance(msg) and AIMessage.isInstance(msg) rather than checking msg.getType() for proper TypeScript narrowing