A2UI Protocol Implementation for Dash - Declarative UI generation for LLM agents.
DashA2UI implements the A2UI (Agent-to-User Interface) Protocol v0.8 for generating declarative, streaming UI payloads that can be rendered by A2UI-compatible clients.
A2UI is designed to be:
- LLM-friendly: Flat adjacency list model, easy for LLMs to generate incrementally
- Secure: Declarative data format, not executable code
- Framework-agnostic: Same payload renders on web, Flutter, etc.
# Core package (no framework dependencies)
pip install "dasha2ui @ git+https://github.com/Cemberk/dasha2ui.git"
# With Dash renderer support
pip install "dasha2ui[dash] @ git+https://github.com/Cemberk/dasha2ui.git"
# Everything
pip install "dasha2ui[all] @ git+https://github.com/Cemberk/dasha2ui.git"git clone https://github.com/Cemberk/dasha2ui.git
cd dasha2ui
pip install -e .[dash] # Editable install with Dash supportpip install dasha2ui[dash]
pip install dasha2ui[all]from dasha2ui import (
A2UISurface, text, row, column, card,
TextUsageHint, Distribution
)
# Create a surface
surface = A2UISurface("my-dashboard")
# Add components
title = surface.add(text("Dashboard", usage_hint=TextUsageHint.H1))
subtitle = surface.add(text("Welcome!", usage_hint=TextUsageHint.BODY))
# Create layout
content = surface.add(column([title.id, subtitle.id]))
# Build A2UI messages
messages = surface.build(root_id=content.id)
# Output as JSON
print(surface.to_json_array(root_id=content.id))from dasha2ui import build_dashboard_ui
messages = build_dashboard_ui(
title="Sales Dashboard",
metrics=[
{"title": "Total Sales", "value_path": "/sales/total", "icon": "shoppingCart"},
{"title": "Orders", "value_path": "/sales/orders", "icon": "payment"},
],
data={"sales": {"total": "$12,345", "orders": "156"}}
)from dasha2ui.renderers.dash_renderer import A2UIRenderer
# Process A2UI messages
renderer = A2UIRenderer()
renderer.process_messages(messages)
# Get Dash component
dash_component = renderer.render()
# Use in your Dash app
app.layout = html.Div([dash_component])DashA2UI supports all A2UI v0.8 standard components:
row()- Horizontal flex layoutcolumn()- Vertical flex layoutlist_component()- Scrollable listcard()- Card container
text()- Text with typography hints (h1-h5, body, caption)image()- Image with sizing hintsicon()- Material Design iconsdivider()- Horizontal/vertical divider
button()- Button with actiontext_field()- Text inputcheckbox()- Checkboxslider()- Slidermultiple_choice()- Selectiontabs()- Tab navigationmodal()- Modal dialog
video()- Video playeraudio_player()- Audio player
Components can bind to a data model using paths:
from dasha2ui import text, BoundString, A2UISurface
surface = A2UISurface("example")
# Bind text to data model path
value = surface.add(text(BoundString.bound("/metrics/total")))
# Set data
surface.set_data({"metrics": {"total": "1,234"}})For progressive UI generation:
from dasha2ui import A2UIStream, text, column
stream = A2UIStream("dashboard")
# Send initial structure
yield stream.begin_rendering("root")
# Stream components
title = text("Loading...", id="title")
yield stream.surface_update([title])
# Update data progressively
yield stream.data_update({"status": "Ready"})A2UI is designed for LLM output. Example prompt:
Generate A2UI JSON to display a dashboard with:
- Title: "Performance Metrics"
- 3 metric cards showing CPU, Memory, Disk usage
Output format: JSON array of A2UI messages
MIT License