Skip to main content

UI Components

The @erdoai/ui package provides React components for rendering agent results, including charts, tables, and formatted content.

Installation

Peer Dependencies:

ErdoProvider

Wrap your app with ErdoProvider to configure the SDK:
Never expose API keys to the browser. For streaming invocations, use ephemeral tokens or proxy streaming. See Integration Patterns for secure patterns.
Config Options:

ContentComponent

The ContentComponent config option allows you to provide a default component for rendering nested content in invocation components (like InvocationEvents, Output, StepInvocation):
This is useful when:
  • 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 ContentComponent as a prop to every component
Components will automatically use the provider’s 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 custom DataFetcher 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
DataFetcher Interface: 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:
Options: Returns:

useDatasetContents

Fetch dataset contents using plain React state (no React Query required):
The hook uses the 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 the components prop:
The components prop is a Record<string, ComponentType> where:
  • Key: The content_type or ui_content_type string (e.g., 'bot_invocation', 'text', 'chart')
  • Value: A React component that receives { content, className } props
When Content encounters a content type, it first checks if there’s a custom renderer in 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:
  1. Add the CSS variables above to your global styles
  2. Configure Tailwind content paths
  3. 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

The Content 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.