Common props ref: Common Props
Box component serves as a container to manage Card instances and command dispatching.
| Property | Description | Type | Default | Version |
|---|---|---|---|---|
| children | Child elements | React.ReactNode | - | - |
| components | Custom component mapping, component names must start with uppercase letters | Record<string, React.ComponentType<any>> | - | - |
| commands | A2UI command object | A2UICommand_v0_9 | XAgentCommand_v0_8 | - | - |
| onAction | Callback function when action is triggered inside Card | (payload: ActionPayload) => void | - | - |
Card component is used to render a single Surface.
| Property | Description | Type | Default | Version |
|---|---|---|---|---|
| id | Surface ID, corresponding to surfaceId in commands | string | - | - |
Data structure for action events.
| Property | Description | Type | Default | Version |
|---|---|---|---|---|
| name | Event name | string | - | - |
| surfaceId | The surfaceId that triggered the action | string | - | - |
| context | Context passed by component, with path references resolved | Record<string, any> | - | - |
When a component triggers an action, X-Card automatically resolves path references in the context to actual values.
In v0.8, action configuration uses array format to define path binding:
{"id": "submit-btn","component": {"Button": {"action": {"name": "agent:send_context_text","context": [{ "key": "username", "value": { "path": "/form/username" } },{ "key": "email", "value": { "path": "/form/email" } }]}}}}
When user clicks the button to trigger action, the context received by onAction callback is automatically resolved:
{"username": { "value": "John" },"email": { "value": "john@example.com" }}
Note:
{ path: "xxx" } format in the context are convertedCommand type for v0.8 version, supporting the following commands:
Update components on a Surface.
| Property | Description | Type | Default | Version |
|---|---|---|---|---|
| surfaceUpdate.surfaceId | Surface ID | string | - | - |
| surfaceUpdate.components | Component list | ComponentWrapper_v0_8[] | - | - |
Component wrapper structure for v0.8 version.
interface ComponentWrapper_v0_8 {id: string;component: {[componentType: string]: {child?: string;children?: string[] | ExplicitList;[key: string]: any | PathValue | LiteralStringValue;};};}
interface ExplicitList {explicitList: string[];}
Update data model (v0.8 format).
| Property | Description | Type | Default | Version |
|---|---|---|---|---|
| dataModelUpdate.surfaceId | Surface ID | string | - | - |
| dataModelUpdate.contents | Data content list | Array<{ key: string; valueMap: Array<{ key: string; valueString: string }> }> | - | - |
Begin rendering.
| Property | Description | Type | Default | Version |
|---|---|---|---|---|
| beginRendering.surfaceId | Surface ID | string | - | - |
| beginRendering.root | Root component ID | string | - | - |
Delete a Surface.
| Property | Description | Type | Default | Version |
|---|---|---|---|---|
| deleteSurface.surfaceId | Surface ID | string | - | - |
Data binding path object.
interface PathValue {path: string;}
Literal string value object (v0.8 specific).
interface LiteralStringValue {literalString: string;}