UI Components
The@erdoai/ui package provides React components for rendering agent results, including charts, tables, and formatted content.
Installation
ErdoProvider
Wrap your app withErdoProvider to configure the SDK:
ContentComponent
TheContentComponent config option allows you to provide a default component for rendering nested content in invocation components (like InvocationEvents, Output, StepInvocation):
- You want to customize how content is rendered across all invocation components
- You have your own Content component with custom renderers
- You want to avoid passing
ContentComponentas a prop to every component
ContentComponent as a default, but you can still override it via props if needed.
Custom Data Fetching
The SDK uses plain React state for data fetching (no React Query required). You can provide a customDataFetcher to:
- Proxy requests through your own backend (keeping API keys server-side)
- Add custom authentication headers or logic
- Transform data before it reaches components
- Use your own API instead of Erdo’s REST endpoints
If no
dataFetcher is provided, the SDK falls back to the REST API using baseUrl and token/authToken for authentication.
Hooks
useThread
Send messages to threads with streaming support:
Returns:
useDatasetContents
Fetch dataset contents using plain React state (no React Query required):DataFetcher from the provider if available, otherwise falls back to the REST API.
useMultipleDatasetContents
Fetch multiple datasets in parallel:Content Renderers
Content
Auto-routes to the appropriate renderer based on content type:Custom Renderers
Override how specific content types are rendered using thecomponents prop:
components prop is a Record<string, ComponentType> where:
- Key: The
content_typeorui_content_typestring (e.g.,'bot_invocation','text','chart') - Value: A React component that receives
{ content, className }props
components, then falls back to built-in renderers.
Individual Renderers
Chart Components
All charts support download functionality via the download button.BarChart
LineChart
PieChart
ScatterChart
HeatmapChart
Chart Props
All chart components accept these common props:Styling
@erdoai/ui components use Tailwind CSS classes and CSS custom properties (variables). You need to configure both for the components to render correctly.
1. Tailwind Configuration
Add@erdoai/ui to your Tailwind content paths:
2. CSS Variables
Components rely on CSS variables for theming. If you’re using shadcn/ui, these are already defined. Otherwise, add them to your global CSS:Using with shadcn/ui
If you’re already using shadcn/ui, the CSS variables are configured automatically. Just ensure@erdoai/ui is in your Tailwind content paths.
Minimal Setup (No shadcn/ui)
If you’re not using shadcn/ui but want Erdo charts to work:- Add the CSS variables above to your global styles
- Configure Tailwind content paths
- Components will use your theme colors automatically
The
--chart-1 through --chart-5 variables are used for chart colors. Customize these to match your brand.Advanced: Custom Content Renderers
TheContent component handles all content types automatically. For advanced use cases, you can override specific content type renderers using the components prop.
Building Block Components
When building custom renderers that need to display nested content (like bot invocations with steps), these building block components are available:Example: Custom Bot Invocation Renderer
Most applications don’t need custom renderers. The default
Content component handles all standard content types including nested bot invocations, charts, tables, and markdown.
