Basic Usage
The <A2UISurface> Component
The core of a2ui-shadcn is the <A2UISurface> component. It handles:
- Parsing A2UI JSON messages
- Managing component state and data model
- Rendering UI components
- Handling user interactions
Minimal Example
tsx
Manual Message Mode
For testing or server-side rendering, provide messages directly:
tsx
WebSocket Transport
For real-time bidirectional communication:
tsx
Server-Sent Events (SSE)
For one-way streaming from server to client:
tsx
Handling Actions
Actions are triggered by user interactions (button clicks, form submissions, etc.):
tsx
Custom Component Registry
Extend the catalog with your own components:
tsx
Your custom component receives A2UI props:
tsx
Theme Customization
Override default theme tokens:
tsx
RTL Layout
Enable right-to-left layout:
tsx
Agents can also control direction via createSurface:
json
Error Handling
Handle surface-level errors:
tsx
Next Steps
- Components Reference - Explore all available components
- Theming Guide - Customize colors and typography
- API Reference - Complete TypeScript API docs