Widgets
What are Widgets?
Section titled βWhat are Widgets?βWidgets are reusable, self-contained UI components built with A2UI. Unlike pages (which are app-specific), widgets can be:
- Used across multiple pages in your project
- Shared with other projects
- Configured with different data sources per usage
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ Widget: KPI Card ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€β ββ βββββββββββ ββ β π β Revenue ββ βββββββββββ $124,500 ββ β² 12.5% from last month ββ ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Used in: βββ Dashboard Page (binds to /revenue) βββ Reports Page (binds to /monthly-summary) βββ Other Project β Widget LibraryWidget vs Page
Section titled βWidget vs Pageβ| Aspect | Widget | Page |
|---|---|---|
| Scope | Reusable anywhere | App-specific |
| Purpose | Self-contained component | Full-screen layout |
| Data | Configured per usage | Bound to app state |
| Sharing | Exportable/importable | Not shareable |
Widget Structure
Section titled βWidget StructureβA widget defines:
- Inputs - Configurable properties
- Components - A2UI structure
- Bindings - Data connections
- Styling - Visual customization
- Actions - User interaction handlers
Example Widget Definition
Section titled βExample Widget Definitionβ{ "id": "kpi-card", "name": "KPI Card", "description": "Displays a key metric with trend indicator", "inputs": { "title": { "type": "string", "required": true }, "value": { "type": "binding", "required": true }, "trend": { "type": "binding" }, "icon": { "type": "string", "default": "chart" } }, "components": [ { "id": "root", "component": { "Card": { "children": { "explicitList": ["header", "content"] } } } }, { "id": "header", "component": { "Row": { "children": { "explicitList": ["icon", "title"] } } } }, { "id": "icon", "component": { "Icon": { "name": { "path": "/inputs/icon" } } } }, { "id": "title", "component": { "Text": { "text": { "path": "/inputs/title" }, "usageHint": "caption" } } }, { "id": "content", "component": { "Column": { "children": { "explicitList": ["value", "trend"] } } } }, { "id": "value", "component": { "Text": { "text": { "path": "/inputs/value" }, "usageHint": "h2" } } }, { "id": "trend", "component": { "Text": { "text": { "path": "/inputs/trend" }, "usageHint": "caption" } } } ]}Creating Widgets
Section titled βCreating WidgetsβFlow-Like lets you create widgets with AI, manually, or both:
Visual Builder
Section titled βVisual BuilderβDesign widgets interactively with drag-and-drop:
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ Widget Builder: KPI Card [Test Data βΎ] ββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββ¬ββββββββββββββββββββ€β β β ββ COMPONENTS β CANVAS β WIDGET INPUTS ββ β β ββ βββββββββ β βββββββββββββββββββββββββββ β Define what can ββ β Text β β β ββββββ β β be configured: ββ βββββββββ β β β π β Revenue β β ββ βββββββββ β β ββββββ $124,500 β β title: string ββ β Icon β β β β² 12.5% β β value: binding ββ βββββββββ β β β β trend: binding ββ βββββββββ β βββββββββββββββββββββββββββ β icon: string ββ β Card β β β ββ βββββββββ β β [+ Add Input] ββ β β ββββββββββββββββ΄ββββββββββββββββββββββββββββββββββββ΄ββββββββββββββββββββ€β [Cancel] [Save Widget] [Export .widget]ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββAI-Generated
Section titled βAI-GeneratedβDescribe the widget to an AI agent:
Create a KPI card widget that displays:- An icon on the left- A title and large value- A trend indicator showing percentage change- Make the trend green if positive, red if negativeThe agent creates the A2UI structureβopen it in the visual builder to refine.
Hybrid Workflow
Section titled βHybrid WorkflowβThe power is in combining both:
| Workflow | Description |
|---|---|
| AI β Refine | Agent creates widget, you polish in builder |
| Build β Enhance | Start manually, ask AI to add features |
| Template β Customize | Pick a starter widget, make it yours |
Everything produces standard A2UI formatβfully interchangeable.
A2UI Standard Components
Section titled βA2UI Standard ComponentsβBuild with A2UIβs standard catalog:
| Category | Components |
|---|---|
| Layout | Row, Column, List |
| Display | Text, Image, Icon, Video, Divider |
| Interactive | Button, TextField, CheckBox, DateTimeInput, Slider |
| Container | Card, Tabs, Modal |
Widget Inputs
Section titled βWidget InputsβInputs make widgets configurable:
{ "inputs": { "title": { "type": "string", "required": true, "description": "Card title" }, "data": { "type": "binding", "required": true, "description": "Data source path" }, "showTrend": { "type": "boolean", "default": true }, "variant": { "type": "enum", "options": ["default", "compact", "large"], "default": "default" } }}Input Types
Section titled βInput Typesβ| Type | Description | Example |
|---|---|---|
string | Text value | "Revenue" |
number | Numeric value | 42 |
boolean | True/false | true |
enum | One of options | "compact" |
binding | Data path | "/metrics/revenue" |
action | Flow to trigger | "submit-form" |
Using Widgets
Section titled βUsing WidgetsβIn Pages
Section titled βIn PagesβReference widgets by ID:
{ "id": "revenue-card", "widgetRef": "kpi-card", "inputs": { "title": "Revenue", "value": "/metrics/revenue", "trend": "/metrics/revenueTrend", "icon": "dollar" }}Multiple Instances
Section titled βMultiple InstancesβUse the same widget with different data:
{ "components": [ { "id": "revenue", "widgetRef": "kpi-card", "inputs": { "title": "Revenue", "value": "/revenue" } }, { "id": "orders", "widgetRef": "kpi-card", "inputs": { "title": "Orders", "value": "/orders" } }, { "id": "customers", "widgetRef": "kpi-card", "inputs": { "title": "Customers", "value": "/customers" } } ]}Sharing Widgets
Section titled βSharing WidgetsβPackage widgets for sharing:
ββββββββββββββββββββββββββββββββββββββββββββ Export Widget ββββββββββββββββββββββββββββββββββββββββββββ€β Widget: KPI Card ββ Version: 1.0.0 ββ ββ β Include styling ββ β Include example data ββ β Include flow dependencies ββ ββ [Cancel] [Export .widget] ββββββββββββββββββββββββββββββββββββββββββββAdd widgets from other projects:
ββββββββββββββββββββββββββββββββββββββββββββ Import Widget ββββββββββββββββββββββββββββββββββββββββββββ€β π Drop .widget file here ββ ββ Or browse from: ββ β’ Local files ββ β’ Widget marketplace ββ β’ Team shared library ββββββββββββββββββββββββββββββββββββββββββββWidget Library
Section titled βWidget LibraryβYour project maintains a widget library:
project/βββ pages/β βββ dashboard.jsonβ βββ reports.jsonβββ widgets/β βββ kpi-card.widget.jsonβ βββ data-table.widget.jsonβ βββ chart-line.widget.jsonβ βββ user-avatar.widget.jsonβββ shared/ βββ imported-widgets/Common Widget Patterns
Section titled βCommon Widget PatternsβData Display
Section titled βData Displayββββββββββββββββββββββββββββββ π Chart Widget ββ ββββββββββββββββββββ ββ β±β² β±β² ββ β± β² β± β² β± ββ β± β²β± β²β± βββββββββββββββββββββββββββββForm Input
Section titled βForm Inputββββββββββββββββββββββββββββββ π Contact Form Widget ββ ββββββββββββββββββββ ββ Name: [____________] ββ Email: [___________] ββ Message: ββ [___________________] ββ [Submit] βββββββββββββββββββββββββββββList Item
Section titled βList Itemββββββββββββββββββββββββββββββ π€ John Doe ββ [email protected] ββ [View] [Edit] βββββββββββββββββββββββββββββFlow Integration
Section titled βFlow IntegrationβWidgets can connect to flows:
{ "actions": { "onSubmit": { "flow": "process-form", "inputs": { "data": "/form/values" } }, "onRefresh": { "flow": "fetch-data", "outputs": { "result": "/widget/data" } } }}Theming
Section titled βThemingβWidgets inherit app theming but can be customized:
{ "styling": { "variants": { "default": { "background": "var(--card-bg)", "borderRadius": "var(--radius-md)" }, "highlighted": { "background": "var(--accent-bg)", "border": "2px solid var(--accent)" } } }}