Instala la habilidad belt CLI:
npx skills add belt-sh/cli
Renderizador de Widgets
UI declarativa desde JSON a través de ui.inference.sh.

Inicio Rápido
npx shadcn@latest add https://ui.inference.sh/r/widgets.json
Uso Básico
import { WidgetRenderer } from "@/registry/blocks/widgets/widget-renderer"
import type { Widget, WidgetAction } from "@/registry/blocks/widgets/types"
const widget: Widget = {
type: 'ui',
title: 'Mi Widget',
children: [
{ type: 'text', value: 'Hola Mundo' },
{ type: 'button', label: 'Haz clic', onClickAction: { type: 'click' } },
],
}
<WidgetRenderer
widget={widget}
onAction={(action, formData) => console.log(action, formData)}
/>
Tipos de Widgets
Diseño
{ "type": "row", "gap": 2, "children": [...] }
{ "type": "col", "gap": 2, "children": [...] }
{ "type": "box", "background": "gradient-ocean", "padding": 4, "radius": "lg", "children": [...] }
Tipografía
{ "type": "title", "value": "Encabezado", "size": "2xl", "weight": "bold" }
{ "type": "text", "value": "Texto del cuerpo", "variant": "bold" }
{ "type": "caption", "value": "Texto pequeño" }
{ "type": "label", "value": "Etiqueta de campo", "fieldName": "email" }
Interactivos
{ "type": "button", "label": "Enviar", "variant": "default", "onClickAction": { "type": "submit" } }
{ "type": "input", "name": "email", "placeholder": "Ingresa correo" }
{ "type": "textarea", "name": "message", "placeholder": "Tu mensaje" }
{ "type": "select", "name": "plan", "options": [{ "value": "pro", "label": "Pro" }] }
{ "type": "checkbox", "name": "agree", "label": "Estoy de acuerdo", "defaultChecked": false }
Visualización
{ "type": "badge", "label": "Nuevo", "variant": "secondary" }
{ "type": "icon", "iconName": "check", "size": "lg" }
{ "type": "image", "src": "https://...", "alt": "Imagen", "width": 100, "height": 100 }
{ "type": "divider" }
Ejemplo: Tarjeta de Vuelo
const flightWidget: Widget = {
type: 'ui',
children: [
{
type: 'box', background: 'gradient-ocean', padding: 4, radius: 'lg', children: [
{
type: 'row', justify: 'between', children: [
{
type: 'col', gap: 1, children: [
{ type: 'caption', value: 'salida' },
{ type: 'title', value: 'SFO', size: '2xl', weight: 'bold' },
]
},
{ type: 'icon', iconName: 'plane', size: 'lg' },
{
type: 'col', gap: 1, align: 'end', children: [
{ type: 'caption', value: 'llegada' },
{ type: 'title', value: 'JFK', size: '2xl', weight: 'bold' },
]
},
]
},
]
},
],
}
Ejemplo: Formulario
const formWidget: Widget = {
type: 'ui',
title: 'Formulario de Contacto',
asForm: true,
children: [
{
type: 'col', gap: 3, children: [
{ type: 'input', name: 'name', placeholder: 'Tu nombre' },
{ type: 'input', name: 'email', placeholder: 'Dirección de correo' },
{ type: 'textarea', name: 'message', placeholder: 'Mensaje' },
{ type: 'button', label: 'Enviar', variant: 'default', onClickAction: { type: 'submit' } },
]
},
],
}
Degradados
| Nombre | Descripción |
|---|---|
gradient-ocean | Degradado azul verde azulado |
gradient-sunset | Degradado naranja rosa |
gradient-purple | Degradado púrpura |
gradient-cool | Degradado azul frío |
gradient-midnight | Degradado azul oscuro |
Manejo de Acciones
const handleAction = (action: WidgetAction, formData?: WidgetFormData) => {
switch (action.type) {
case 'submit':
console.log('Datos del formulario:', formData)
break
case 'click':
console.log('Botón presionado')
break
}
}
Habilidades Relacionadas
# Componente de agente completo
npx skills add inference-sh/skills@agent-ui
# Bloques de UI de chat
npx skills add inference-sh/skills@chat-ui
# UI de herramientas
npx skills add inference-sh/skills@tools-ui
Documentación
- Visión General de Widgets - Comprendiendo los widgets
- Esquema de Widgets - Estructura JSON de widgets
- Agentes Que Generan UI - Construyendo UIs generativas
Documentación del componente: ui.inference.sh/blocks/widgets