Python functions for building dashboard UIs. Each function returns a dict that the frontend renders as a real UI element — 36 components organized into tiers.
A metric card with optional delta indicator.
| Parameter | Type | Required | Default | Description |
|-----------|------|----------|---------|-------------|
| label | str | ✅ | — | Metric label |
label
str
| value | Any | ✅ | — | Main metric value |
value
Any
| delta | str | ❌ | None | Change indicator (e.g. "+5%") |
delta
None
| delta_color | str | ❌ | "normal" | "normal", "inverse", or "off" |
delta_color
"normal"
"inverse"
"off"
A progress bar.
| label | str | ✅ | — | Label above the bar |
| value | int\|float | ✅ | — | Current value |
int\|float
| max_value | int\|float | ❌ | 100 | Maximum value |
max_value
100
An alert/notification box.
| message | str | ✅ | — | Alert body text |
message
| variant | str | ❌ | "info" | "info", "success", "warning", "error" |
variant
"info"
"success"
"warning"
"error"
| title | str | ❌ | None | Optional bold title |
title
An inline badge/tag.
| text | str | ✅ | — | Badge label |
text
| variant | str | ❌ | "default" | "default", "secondary", "destructive", "outline" |
"default"
"secondary"
"destructive"
"outline"
A horizontal separator line. No parameters.
A tabbed container.
| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| items | Sequence[dict] | ✅ | List of {"label": str, "children": [comp_dicts]} |
items
Sequence[dict]
{"label": str, "children": [comp_dicts]}
A collapsible accordion.
| items | Sequence[dict] | ✅ | List of {"title": str, "content": str_or_comp} |
{"title": str, "content": str_or_comp}
An image with optional caption.
| src | str | ✅ | — | Image URL or path |
src
| alt | str | ❌ | "" | Alt text |
alt
""
| caption | str | ❌ | None | Caption below image |
caption
| width | str | ❌ | None | CSS width (e.g. "300px", "50%") |
width
"300px"
"50%"
A code block with syntax highlighting.
| code | str | ✅ | — | Source code text |
code
| language | str | ❌ | "text" | Language for highlighting |
language
"text"
A formatted JSON viewer.
| data | Any | ✅ | Any JSON-serializable data |
data
---
| label | str | ✅ | — | Input label |
| value | str | ❌ | "" | Default value |
| placeholder | str | ❌ | "" | Placeholder text |
placeholder
| value | int\|float | ❌ | 0 | Default value |
0
| min_val | int\|float | ❌ | None | Minimum allowed |
min_val
| max_val | int\|float | ❌ | None | Maximum allowed |
max_val
| step | int\|float | ❌ | 1 | Increment step |
step
1
| options | Sequence[str] | ✅ | — | Option strings |
options
Sequence[str]
| value | str | ❌ | "" | Default selected |
| min_val | int\|float | ❌ | 0 | Minimum |
| max_val | int\|float | ❌ | 100 | Maximum |
| label | str | ✅ | — | Checkbox label |
| checked | bool | ❌ | False | Default state |
checked
bool
False
| label | str | ✅ | — | Switch label |
| label | str | ✅ | — | Group label |
| rows | int | ❌ | 4 | Visible rows |
rows
int
4
| options | Sequence[str] | ✅ | — | Available choices |
| value | Sequence[str] | ❌ | () | Default selections |
()
| value | str | ❌ | None | ISO date string |
| value | str | ❌ | None | "HH:MM" string |
"HH:MM"
| value | str | ❌ | "#000000" | Default hex color |
"#000000"
A container wrapper with optional title.
| children | Sequence[dict] | ✅ | — | Child component dicts |
children
| title | str | ❌ | None | Optional heading |
A collapsible section.
| title | str | ✅ | — | Section heading |
| children | Sequence[dict] | ✅ | — | Content components |
| expanded | bool | ❌ | False | Initially expanded? |
expanded
A horizontal divider with optional center text.
| text | str | ❌ | None | Label in the middle of the line |
A heading element.
| text | str | ✅ | — | Heading text |
| level | int | ❌ | 1 | Heading level 1–6 |
level
A markdown-rendered text block.
| content | str | ✅ | Markdown content string |
content
A hyperlink.
| text | str | ✅ | — | Link text |
| href | str | ✅ | — | URL |
href
| external | bool | ❌ | False | Open in new tab? |
external
A row of buttons.
| buttons | Sequence[dict] | ✅ | List of {"label": str, "variant": str} |
buttons
{"label": str, "variant": str}
A grid of stat/metric cards.
| stats | Sequence[dict] | ✅ | List of {"label": str, "value": Any, "delta": str} |
stats
{"label": str, "value": Any, "delta": str}
An avatar image or initials.
| src | str | ❌ | None | Image URL |
| name | str | ❌ | None | Display name |
name
| fallback | str | ❌ | None | Fallback text (e.g. initials) |
fallback
A callout/highlight box.
| content | str | ✅ | — | Callout body text |
An empty state placeholder.
| text | str | ❌ | "No data" | Placeholder message |
"No data"
A loading spinner with text.
| text | str | ❌ | "Loading..." | Loading message |
"Loading..."
| src | str | ✅ | — | Audio file URL |
| autoplay | bool | ❌ | False | Auto-play? |
autoplay
| src | str | ✅ | — | Video file URL |
| poster | str | ❌ | None | Poster image URL |
poster
| label | str | ✅ | — | Button label |
| href | str | ✅ | — | File URL |
| filename | str | ❌ | None | Suggested filename |
filename
An image/media gallery grid.
| items | Sequence[dict] | ✅ | List of {"src": str, "alt": str, "caption": str} |
{"src": str, "alt": str, "caption": str}
A toast notification.
| message | str | ✅ | — | Notification text |
| duration | int | ❌ | 3000 | Auto-dismiss ms |
duration
3000
A modal dialog.
| title | str | ✅ | — | Dialog heading |
| description | str | ❌ | None | Subtitle |
description
Small muted caption text.
| text | str | ✅ | Caption content |
Raw HTML embed (trusted content only).
| content | str | ✅ | HTML string |
A skeleton loading placeholder.
| width | str | ❌ | None | CSS width |
| height | str | ❌ | None | CSS height |
height
| variant | str | ❌ | "text" | "text", "card", or "avatar" |
"card"
"avatar"
Wrap a component with a hover tooltip.
| child | dict | ✅ | Component to wrap |
child
dict
| content | str | ✅ | Tooltip text |
A breadcrumb navigation trail.
| items | Sequence[dict] | ✅ | List of {"label": str, "href": str\|None} |
{"label": str, "href": str\|None}
Pagination controls.
| total | int | ✅ | — | Total items |
total
| page | int | ❌ | 1 | Current page (1-based) |
page
| per_page | int | ❌ | 10 | Items per page |
per_page
10
A key-value display list.
| items | Sequence[dict] | ✅ | — | List of {"label": str, "value": Any} |
{"label": str, "value": Any}
A popover overlay triggered by a component.
| trigger | dict | ✅ | Component that triggers the popover |
trigger
| children | Sequence[dict] | ✅ | Content inside the popover |
Components are designed to compose. Use columns() for horizontal layout within a layout():
columns()
layout()
| Category | Components | Count |
|----------|-----------|-------|
| Core | layout, card, columns, table, text, chart | 6 |
layout
card
columns
table
chart
| Essential | metric, progress_bar, alert, badge, separator, tabs, accordion, image_display, code_block, json_view | 10 |
metric
progress_bar
alert
badge
separator
tabs
accordion
image_display
code_block
json_view
| Form Inputs | text_input, number_input, select_input, slider_input, checkbox_input, switch_input, radio_input, textarea_input, multiselect_input, date_input, time_input, color_picker_input | 12 |
text_input
number_input
select_input
slider_input
checkbox_input
switch_input
radio_input
textarea_input
multiselect_input
date_input
time_input
color_picker_input
| Layout & Advanced | container, expander, divider, header, markdown_text, link, button_group, stat_group, avatar, callout, empty, spinner | 12 |
container
expander
divider
header
markdown_text
link
button_group
stat_group
avatar
callout
empty
spinner
| Media | audio_player, video_player, file_download, gallery | 4 |
audio_player
video_player
file_download
gallery
| Dashboard | toast, dialog, caption, html_embed, skeleton, tooltip_wrap | 6 |
toast
dialog
html_embed
skeleton
tooltip_wrap
| Navigation | breadcrumb, pagination, key_value_list, popover | 4 |
breadcrumb
pagination
key_value_list
popover
| Total | | 54 |
The dashboard.js renderer supports any dict with a type key. Unknown types render as formatted JSON, making it safe to experiment:
dashboard.js
type
Understanding how components flow from Python to the browser.
1. Python: Call aiui.card("Revenue", value="$1,500") — returns a dict:
aiui.card("Revenue", value="$1,500")
2. Server: @aiui.page() handler returns aiui.layout([...]):
@aiui.page()
aiui.layout([...])
3. API: GET /api/pages/{id}/data returns the JSON
GET /api/pages/{id}/data
4. Frontend: dashboard.js detects _components key and calls renderComponents():
_components
renderComponents()
5. Renderer: renderComponent(comp) dispatches on comp.type:
renderComponent(comp)
comp.type
6. DOM: Each renderer creates HTML elements with db-* CSS classes
db-*
The magic key that triggers structured rendering:
aiui.layout(children) automatically wraps children in {"_components": [...]}.
aiui.layout(children)
{"_components": [...]}
Every component function returns a dict with:
| Key | Required | Description |
|-----|----------|-------------|
| type | ✅ | Component type name (e.g. "card", "table") |
"table"
| Other keys | Varies | Component-specific properties |
All components use db-* prefixed CSS classes:
| Component | CSS Class |
|-----------|-----------|
| Card | .db-card, .db-card-title, .db-card-value, .db-card-footer |
.db-card
.db-card-title
.db-card-value
.db-card-footer
| Table | .db-viewer table |
.db-viewer table
| Alert | .db-alert, .db-alert-info, .db-alert-success, etc. |
.db-alert
.db-alert-info
.db-alert-success
| Badge | .db-badge, .db-badge-secondary, .db-badge-destructive |
.db-badge
.db-badge-secondary
.db-badge-destructive
| Tabs | .db-tabs, .db-tab-list, .db-tab-btn, .db-tab-panel |
.db-tabs
.db-tab-list
.db-tab-btn
.db-tab-panel
To add a new component type:
1. Python: Add function to ui.py:
ui.py
2. Frontend: Add renderer to dashboard.js:
3. CSS: Add styles for .db-timeline
.db-timeline
Until the frontend renderer is added, unknown types render as formatted JSON.