← 返回
未分类 中文

Widgets Ui

Declarative UI widgets from JSON for React/Next.js from ui.inference.sh. Render rich interactive UIs from structured agent responses. Capabilities: forms, bu...
声明式 UI 组件(基于 JSON),适用于 React/Next.js(来源 ui.inference.sh),可将结构化代理响应渲染为富交互式 UI。功能包括表单、按钮等。
okaris
未分类 clawhub v0.1.5 1 版本 100000 Key: 无需
★ 0
Stars
📥 669
下载
💾 3
安装
1
版本
#latest

概述

Widget Renderer

Declarative UI from JSON via ui.inference.sh.

!Widget Renderer

Quick Start

npx shadcn@latest add https://ui.inference.sh/r/widgets.json

Basic Usage

import { WidgetRenderer } from "@/registry/blocks/widgets/widget-renderer"
import type { Widget, WidgetAction } from "@/registry/blocks/widgets/types"

const widget: Widget = {
  type: 'ui',
  title: 'My Widget',
  children: [
    { type: 'text', value: 'Hello World' },
    { type: 'button', label: 'Click me', onClickAction: { type: 'click' } },
  ],
}

<WidgetRenderer
  widget={widget}
  onAction={(action, formData) => console.log(action, formData)}
/>

Widget Types

Layout

{ "type": "row", "gap": 2, "children": [...] }
{ "type": "col", "gap": 2, "children": [...] }
{ "type": "box", "background": "gradient-ocean", "padding": 4, "radius": "lg", "children": [...] }

Typography

{ "type": "title", "value": "Heading", "size": "2xl", "weight": "bold" }
{ "type": "text", "value": "Body text", "variant": "bold" }
{ "type": "caption", "value": "Small text" }
{ "type": "label", "value": "Field label", "fieldName": "email" }

Interactive

{ "type": "button", "label": "Submit", "variant": "default", "onClickAction": { "type": "submit" } }
{ "type": "input", "name": "email", "placeholder": "Enter email" }
{ "type": "textarea", "name": "message", "placeholder": "Your message" }
{ "type": "select", "name": "plan", "options": [{ "value": "pro", "label": "Pro" }] }
{ "type": "checkbox", "name": "agree", "label": "I agree", "defaultChecked": false }

Display

{ "type": "badge", "label": "New", "variant": "secondary" }
{ "type": "icon", "iconName": "check", "size": "lg" }
{ "type": "image", "src": "https://...", "alt": "Image", "width": 100, "height": 100 }
{ "type": "divider" }

Example: Flight Card

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: 'departure' },
                { type: 'title', value: 'SFO', size: '2xl', weight: 'bold' },
              ]
            },
            { type: 'icon', iconName: 'plane', size: 'lg' },
            {
              type: 'col', gap: 1, align: 'end', children: [
                { type: 'caption', value: 'arrival' },
                { type: 'title', value: 'JFK', size: '2xl', weight: 'bold' },
              ]
            },
          ]
        },
      ]
    },
  ],
}

Example: Form

const formWidget: Widget = {
  type: 'ui',
  title: 'Contact Form',
  asForm: true,
  children: [
    {
      type: 'col', gap: 3, children: [
        { type: 'input', name: 'name', placeholder: 'Your name' },
        { type: 'input', name: 'email', placeholder: 'Email address' },
        { type: 'textarea', name: 'message', placeholder: 'Message' },
        { type: 'button', label: 'Send', variant: 'default', onClickAction: { type: 'submit' } },
      ]
    },
  ],
}

Gradients

NameDescription
-------------------
gradient-oceanBlue teal gradient
gradient-sunsetOrange pink gradient
gradient-purplePurple gradient
gradient-coolCool blue gradient
gradient-midnightDark blue gradient

Handling Actions

const handleAction = (action: WidgetAction, formData?: WidgetFormData) => {
  switch (action.type) {
    case 'submit':
      console.log('Form data:', formData)
      break
    case 'click':
      console.log('Button clicked')
      break
  }
}

Related Skills

# Full agent component
npx skills add inference-sh/skills@agent-ui

# Chat UI blocks
npx skills add inference-sh/skills@chat-ui

# Tool UI
npx skills add inference-sh/skills@tools-ui

Documentation

Component docs: ui.inference.sh/blocks/widgets

版本历史

共 1 个版本

  • v0.1.5 当前
    2026-05-12 04:41 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

developer-tools

Python Executor

okaris
通过 [inference.sh](https://inference.sh) 在安全沙箱环境中执行 Python 代码。预装:NumPy、Pandas、Matplotlib、requests、BeautifulSoup 等。
★ 3 📥 8,747
content-creation

Ai Image Generation

okaris
通过 inference.sh CLI 使用 FLUX、Gemini、Grok、Seedream、Reve 及 50 多种模型生成 AI 图像。
★ 2 📥 8,324
data-analysis

Speech To Text

okaris
通过 inference.sh CLI 使用 Whisper 模型将音频转录为文本。模型:Fast Whisper Large V3、Whisper V3 Large。功能:转录、翻译等。
★ 0 📥 3,632