UI Components¶
The @modernpath/agent-ui-react package provides a complete set of React components, hooks, and backend factories for building AI agent interfaces. All components ship with inline CSS -- no external CSS framework or stylesheet imports required.
Installation¶
Requirements¶
| Requirement | Minimum Version |
|---|---|
| React | 18.0+ |
| ReactDOM | 18.0+ |
| TypeScript | 5.0+ (recommended) |
Component Categories¶
-
Chat
Full-featured chat interfaces with streaming support, message history, and plan visualization. Use
AgentChatfor a single-agent view orAgentConsolefor a multi-agent switchable interface. -
Plan & Execution
Visualize agent planning steps and execution results.
AgentPlanStepsrenders the agent's numbered plan, whileAgentExecutionDetailsshows expandable step-by-step results with status indicators. -
Grounding
Display RAG retrieval results, attached canonical documents, grounding policy badges, and research details. These components render the grounding context returned by the agent backend.
-
Traces
Explore and debug agent executions with
TraceExplorerfor paginated trace lists,TraceTimelinefor span waterfalls, andTraceSpanDetailfor inspecting individual span inputs and outputs. -
Admin
Administration interfaces for managing knowledge base stores and documents.
KnowledgeBaseManagerprovides a full CRUD interface for document ingestion and ground truth management. -
Hooks
Low-level React hooks for building custom layouts.
useAgentChat,useTraceExplorer,useTraceDetail, anduseConversationsprovide the same state management used by the built-in components.
Backend Factory Pattern¶
UI components do not hardcode HTTP endpoints. Instead, they accept a backend object that abstracts communication with your server. You create backends using factory functions:
import {
createHttpAgentBackend,
createSseAgentBackend,
createHttpTraceBackend,
createHttpConversationBackend,
} from "@modernpath/agent-ui-react";
// HTTP backend (request/response)
const httpBackend = createHttpAgentBackend({
baseUrl: "https://api.example.com",
getHeaders: () => ({ Authorization: `Bearer ${token}` }),
});
// SSE backend (streaming)
const sseBackend = createSseAgentBackend({
baseUrl: "https://api.example.com",
getHeaders: () => ({ Authorization: `Bearer ${token}` }),
});
// Trace backend
const traceBackend = createHttpTraceBackend({
baseUrl: "https://api.example.com",
getHeaders: () => ({ Authorization: `Bearer ${token}` }),
});
// Conversation backend
const conversationBackend = createHttpConversationBackend({
baseUrl: "https://api.example.com",
getHeaders: () => ({ Authorization: `Bearer ${token}` }),
});
Styling¶
All components use inline CSS. There are no external stylesheets to import and no CSS-in-JS runtime dependency. Components are designed with a neutral, professional appearance that works in both light and dark contexts.
No CSS framework required
The package does not depend on Tailwind, Emotion, styled-components, or any other CSS framework. Styles are scoped to each component via inline style attributes.
Quick Example¶
import React from "react";
import {
AgentChat,
createSseAgentBackend,
} from "@modernpath/agent-ui-react";
const backend = createSseAgentBackend({
baseUrl: "/api",
getHeaders: () => ({
Authorization: `Bearer ${localStorage.getItem("token")}`,
}),
});
export function App() {
return (
<AgentChat
backend={backend}
auditingId={1}
agentType="qa-chat"
title="Support Assistant"
placeholder="Ask a question..."
stream
/>
);
}
TypeScript Types¶
All components, hooks, and backend factories are fully typed. See the TypeScript Types Reference for complete interface definitions.
Next Steps¶
- Chat Components -- build chat interfaces with
AgentChatorAgentConsole - Hooks -- use
useAgentChatand other hooks for custom layouts - Backend Factories -- configure HTTP and SSE backends
- TypeScript Types -- explore all exported types