widget renderer
renders declarative ui from json. agents return widget data, the renderer turns it into interactive components.
how it works
widgets are json objects describing ui structure. the renderer recursively builds react components from nodes like box, row, text, button, etc.
1{2 "type": "ui",3 "children": [4 {5 "type": "box",6 "background": "gradient-purple",7 "padding": 4,8 "radius": "lg",9 "children": [10 { "type": "title", "value": "Hello World", "size": "xl" },11 { "type": "caption", "value": "This is a widget" },12 {13 "type": "button",14 "label": "Click me",15 "onClickAction": { "type": "greet" }16 }17 ]18 }19 ]20}click "show data" on any example below to see its json structure.
gallery
compact widgets for card-style layouts.
AAPL
$178.72
Apple Inc. • NASDAQ
The Weeknd
Sarah replied: "This looks amazing!"
2 minutes ago
Alex Chen
Product Designer
posts
followers
Order Confirmed
Order #
#ORD-2847Delivery
Jan 24, 2-4pmTotal
$84.50
24°C
Sunny
San Francisco
MONTHLY REVENUE
$48,290
+12%vs $43,120 last month
FOCUS TIME
24:59
3 min
Driver arriving
Pickup
123 Main StFlight Booked
SFO
10:30 AM
→
NYC
6:45 PM
United Airlines • UA 234 • Jan 28
Payment Sent
$250.00
to @johndoe
MON
24
Design Review
2:00 PM - 3:00 PM
Zoom • 4 attendees
real-world examples
production-ready widget patterns inspired by popular apps.
flight tracker
real-time flight status card with minHeight
DEPARTURE
SFO
San Francisco5h 45m
on timeARRIVAL
JFK
New Yorkweather forecast
current conditions with minHeight
San Francisco
Partly Cloudy
68°
H: 72° L: 58°
task checklist
interactive to-do list with onCheckedChangeAction
email composer
draft email with form fields
calendar event
event creation with date and time
FRIDAY
28
12:00 - 12:45 PM
1:00 - 2:00 PM
3:30 - 4:00 PM
shopping cart
order summary with items and totals
Large • Oat Milk • Less Ice
Medium • Regular Sugar
Subtotal
$12.25Tax
$1.07$13.32
text & content
primitives for displaying text, titles, captions, and badges.
text variants
title sizes
Small (sm)
Medium (md)
Large (lg)
Extra Large (xl)
badges
layout
row, column, and box for composing complex layouts.
row - horizontal layout
box - container with background
form elements
interactive inputs, selects, and checkboxes.
input
select
checkbox
backgrounds
gradient presets and semantic surfaces.
gradient presets
actions
interactive elements with onClickAction, onChangeAction, and loading states.
button variants
buttons with onClickAction
loading behavior
buttons show loading state during action execution
action with payload
actions can include data payloads
confirmation dialog
inline buttons instead of card footer actions
form with actions
card as form with inputs and submit button
installation
1npx shadcn@latest add https://ui.inference.sh/r/widgets.jsonusage
1import { WidgetRenderer } from '@/components/widgets/widget-renderer'2import type { Widget, WidgetAction } from '@/registry/blocks/agent/types'34export function MyWidget() {5 const widget: Widget = {6 type: 'ui',7 title: 'Hello',8 children: [9 { type: 'text', value: 'Welcome to widgets!' },10 {11 type: 'button',12 label: 'Click me',13 onClickAction: { type: 'greet' }14 },15 ],16 }1718 const handleAction = (action: WidgetAction) => {19 console.log('Action triggered:', action)20 }2122 return <WidgetRenderer widget={widget} onAction={handleAction} />23}