logoAnt Design X

⌘ K
DesignDevelopmentComponentsX MarkdownX SDKX CardX SkillPlayground
  • Introduction
  • A2UI v0.8
  • A2UI v0.9

A2UI v0.9

API

Common props ref: Common Props

BoxProps

Box component serves as a container to manage Card instances and command dispatching.

PropertyDescriptionTypeDefaultVersion
childrenChild elementsReact.ReactNode--
componentsCustom component mapping, component names must start with uppercase lettersRecord<string, React.ComponentType<any>>--
commandsA2UI command objectA2UICommand_v0_9 | XAgentCommand_v0_8--
onActionCallback function when action is triggered inside Card(payload: ActionPayload) => void--

CardProps

Card component is used to render a single Surface.

PropertyDescriptionTypeDefaultVersion
idSurface ID, corresponding to surfaceId in commandsstring--

ActionPayload

Data structure for action events.

PropertyDescriptionTypeDefaultVersion
nameEvent namestring--
surfaceIdThe surfaceId that triggered the actionstring--
contextContext passed by component, with path references resolvedRecord<string, any>--

Action Context Path Reference Resolution

When a component triggers an action, X-Card automatically resolves path references in the context to actual values.

Path Reference Format

Use { path: string } format to bind values from dataModel in action configuration:

json
{
"id": "submit-btn",
"component": "Button",
"action": {
"event": {
"name": "agent:send_context_text",
"context": {
"username": { "path": "/form/username", "label": "Username" },
"email": { "path": "/form/email", "label": "Email" }
}
}
}
}

Resolution Result

When user clicks the button to trigger action, the context received by onAction callback is automatically resolved:

json
{
"username": { "value": "John", "label": "Username" },
"email": { "value": "john@example.com", "label": "Email" }
}

Note:

  • Only values in { path: "xxx" } format in the context are converted
  • Actual values passed by component (e.g., { value: "actual_value" }) are not incorrectly converted
  • Other properties (like label) are preserved, only path is replaced with value

A2UICommand_v0_9

Command type for v0.9 version, supporting the following commands:

CreateSurfaceCommand

Create a new Surface.

PropertyDescriptionTypeDefaultVersion
versionVersion number'v0.9'--
createSurface.surfaceIdSurface IDstring--
createSurface.catalogIdComponent catalog URL or local identifierstring--

UpdateComponentsCommand

Update components on a Surface.

PropertyDescriptionTypeDefaultVersion
versionVersion number'v0.9'--
updateComponents.surfaceIdSurface IDstring--
updateComponents.componentsComponent listBaseComponent_v0_9[]--

BaseComponent_v0_9

typescript
interface BaseComponent_v0_9 {
id: string;
component: string;
child?: string;
children?: string[];
[key: string]: any | PathValue;
}

UpdateDataModelCommand

Update data model.

PropertyDescriptionTypeDefaultVersion
versionVersion number'v0.9'--
updateDataModel.surfaceIdSurface IDstring--
updateDataModel.pathData pathstring--
updateDataModel.valueData valueany--

DeleteSurfaceCommand

Delete a Surface.

PropertyDescriptionTypeDefaultVersion
versionVersion number'v0.9'--
deleteSurface.surfaceIdSurface IDstring--

PathValue

Data binding path object.

typescript
interface PathValue {
path: string;
}

Catalog

Component catalog definition.

typescript
interface Catalog {
$schema?: string;
$id?: string;
title?: string;
description?: string;
catalogId?: string;
components?: Record<string, CatalogComponent>;
functions?: Record<string, any>;
$defs?: Record<string, any>;
}

CatalogComponent

Component definition in Catalog.

typescript
interface CatalogComponent {
type: 'object';
allOf?: any[];
properties?: Record<string, any>;
required?: string[];
[key: string]: any;
}

Catalog Methods

registerCatalog

Register a local catalog.

typescript
registerCatalog(catalog: Catalog): void

loadCatalog

Load a catalog (supports remote URL or locally registered schema).

typescript
loadCatalog(catalogId: string): Promise<Catalog>

validateComponent

Validate whether a component conforms to catalog definition.

typescript
validateComponent(catalog: Catalog, componentName: string, componentProps: Record<string, any>): boolean

clearCatalogCache

Clear catalog cache.

typescript
clearCatalogCache(): void
Basic

Basic example of implementing A2UI v0.9 protocol with XCard. Demonstrates how to use XAgentCommand_v0_9 commands with a local catalog.json to create an interactive card for a coffee booking scenario. The v0.9 version introduces a more concise command structure and catalog mechanism.

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code
Progressive

Progressive loading example of implementing A2UI v0.9 protocol with XCard. Demonstrates how to load product data in batches and progressively update components using updateComponents commands, combined with a loading indicator to show progress and achieve a smooth loading experience.

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code
Streaming

Streaming content and real-time updates example implementing A2UI v0.9 protocol with XCard. Demonstrates streaming display of AI recommendation results, progressive component loading animations, and loading progress indicators with catalog mechanism.

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code
Nested Interaction

Complex interaction and nested components example implementing A2UI v0.9 protocol with XCard. Demonstrates expandable detail cards, tree file browser, and accordion folding panels with catalog mechanism.

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code
Multi Card Sync

Multi-card coordination and state synchronization example implementing A2UI v0.9 protocol with XCard. Demonstrates data sharing between multiple Surfaces, cross-card communication, and real-time price calculation in a shopping cart scenario with catalog mechanism.

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code
Filter Search

Dynamic data filtering and search example implementing A2UI v0.9 protocol with XCard. Demonstrates how to use antd components with catalog mechanism for real-time search, multi-condition filtering, and dynamic result updates.

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code
Form Validation

Form validation and error handling example implementing A2UI v0.9 protocol with XCard. Demonstrates how to use antd Form components with catalog mechanism for real-time validation, error state management, and multi-step form workflows.

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code
填写表单后点击提交,观察 onAction 回调中 context 的变化
onAction 回调日志(path 引用已解析):
暂无日志,请填写表单后提交
Action Context Resolve

Demonstrates X-Card automatically resolving path references in action context to actual values when an action is triggered.

When a component triggers an action (like submitting a form), X-Card will automatically convert the { path: "xxx" } format in the action configuration to { value: "actual_value" } format, making it convenient for external code to use the resolved values directly.

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code