Get the FREE Ultimate OpenClaw Setup Guide →

json-render-ui

Scanned
npx machina-cli add skill oaustegard/claude-skills/json-render-ui --openclaw
Files (1)
SKILL.md
7.6 KB

JSON Render UI

Overview

Transform natural language UI requests into working dashboards and applications. Claude acts as the translation layer (prompt → JSON), the skill provides the rendering runtime (JSON → UI).

Architecture:

User prompt → Claude (constrained by catalog) → UITree JSON → Preact renderer → UI

Output Format

Claude emits a UITree structure:

{
  "root": "main",
  "elements": {
    "main": {
      "key": "main",
      "type": "Grid",
      "props": { "columns": 2, "gap": "md" },
      "children": ["metric1", "metric2"]
    },
    "metric1": {
      "key": "metric1",
      "type": "Metric",
      "props": {
        "label": "Revenue",
        "valuePath": "/revenue",
        "format": "currency"
      }
    },
    "metric2": {
      "key": "metric2",
      "type": "Metric",
      "props": {
        "label": "Growth",
        "valuePath": "/growth",
        "format": "percent"
      }
    }
  },
  "data": {
    "revenue": 125000,
    "growth": 0.15
  }
}

Component Catalog

Claude can ONLY use these components. This is the guardrail.

Layout Components

ComponentPropsChildrenDescription
Cardtitle?, description?, padding?: sm|md|lgYesContainer with optional header
Gridcolumns?: 1-4, gap?: sm|md|lgYesCSS grid layout
Stackdirection?: horizontal|vertical, gap?: sm|md|lg, align?: start|center|end|stretchYesFlexbox stack

Data Display

ComponentPropsChildrenDescription
Metriclabel, valuePath, format?: number|currency|percent, trend?: up|down|neutral, trendValue?NoSingle KPI display
Charttype: bar|line|pie|area, dataPath, title?, height?NoData visualization
TabledataPath, columns: [{key, label, format?: text|currency|date|badge}]NoTabular data
ListdataPath, emptyMessage?YesRendered list from array

Interactive

ComponentPropsChildrenDescription
Buttonlabel, action, variant?: primary|secondary|danger|ghost, size?: sm|md|lg, disabled?NoClickable action
Selectlabel?, bindPath, options: [{value, label}], placeholder?NoDropdown select
DatePickerlabel?, bindPath, placeholder?NoDate input

Typography

ComponentPropsChildrenDescription
Headingtext, level?: h1|h2|h3|h4NoSection heading
Textcontent, variant?: body|caption|label, color?: default|muted|success|warning|dangerNoText paragraph

Status

ComponentPropsChildrenDescription
Badgetext, variant?: default|success|warning|danger|infoNoStatus indicator
Alerttype: info|success|warning|error, title, message?, dismissible?NoNotification banner

Special

ComponentPropsChildrenDescription
Dividerlabel?NoVisual separator
Emptytitle, description?, action?, actionLabel?NoEmpty state

Data Binding

Props ending in Path (e.g., valuePath, dataPath, bindPath) reference the data model using JSON Pointer syntax:

  • /revenuedata.revenue
  • /users/0/namedata.users[0].name
  • /filters/dateRangedata.filters.dateRange

Visibility Conditions

Any element can have a visible property:

{
  "type": "Alert",
  "props": { "type": "error", "title": "Error" },
  "visible": { "path": "/hasError" }
}

Visibility expressions:

  • true / false — Static
  • { "path": "/some/path" } — Truthy check
  • { "and": [...] } — All conditions true
  • { "or": [...] } — Any condition true
  • { "not": {...} } — Negation
  • { "eq": [a, b] } — Equality

Generating Output

Step 1: Emit UITree JSON

Analyze the user's request and emit a UITree structure. Include sample data that matches the schema.

Step 2: Create Artifact

Create an HTML artifact that:

  1. Embeds the UITree JSON
  2. Imports the renderer from assets/renderer.js (inline it)
  3. Renders the UI

Use the template in assets/template.html.

Constraints

DO:

  • Use only catalog components
  • Provide realistic sample data
  • Use semantic component choices (Metric for KPIs, Table for tabular data)
  • Keep trees flat (no deep nesting beyond 3 levels)

DO NOT:

  • Invent new component types
  • Use arbitrary HTML/CSS
  • Omit required props
  • Create deeply nested structures

Example

User: "Create a sales dashboard with revenue, orders, and a chart showing monthly trends"

Claude outputs:

{
  "root": "dashboard",
  "elements": {
    "dashboard": {
      "key": "dashboard",
      "type": "Stack",
      "props": { "direction": "vertical", "gap": "lg" },
      "children": ["header", "metrics", "chartCard"]
    },
    "header": {
      "key": "header",
      "type": "Heading",
      "props": { "text": "Sales Dashboard", "level": "h1" }
    },
    "metrics": {
      "key": "metrics",
      "type": "Grid",
      "props": { "columns": 3, "gap": "md" },
      "children": ["revenue", "orders", "avgOrder"]
    },
    "revenue": {
      "key": "revenue",
      "type": "Card",
      "props": { "padding": "md" },
      "children": ["revenueMetric"]
    },
    "revenueMetric": {
      "key": "revenueMetric",
      "type": "Metric",
      "props": {
        "label": "Total Revenue",
        "valuePath": "/revenue",
        "format": "currency",
        "trend": "up",
        "trendValue": "12%"
      }
    },
    "orders": {
      "key": "orders",
      "type": "Card",
      "props": { "padding": "md" },
      "children": ["ordersMetric"]
    },
    "ordersMetric": {
      "key": "ordersMetric",
      "type": "Metric",
      "props": {
        "label": "Orders",
        "valuePath": "/orders",
        "format": "number"
      }
    },
    "avgOrder": {
      "key": "avgOrder",
      "type": "Card",
      "props": { "padding": "md" },
      "children": ["avgMetric"]
    },
    "avgMetric": {
      "key": "avgMetric",
      "type": "Metric",
      "props": {
        "label": "Avg Order Value",
        "valuePath": "/avgOrderValue",
        "format": "currency"
      }
    },
    "chartCard": {
      "key": "chartCard",
      "type": "Card",
      "props": { "title": "Monthly Trends", "padding": "md" },
      "children": ["chart"]
    },
    "chart": {
      "key": "chart",
      "type": "Chart",
      "props": {
        "type": "line",
        "dataPath": "/monthlyData",
        "height": 300
      }
    }
  },
  "data": {
    "revenue": 284500,
    "orders": 1247,
    "avgOrderValue": 228,
    "monthlyData": [
      { "month": "Jan", "value": 18000 },
      { "month": "Feb", "value": 22000 },
      { "month": "Mar", "value": 28000 },
      { "month": "Apr", "value": 24000 },
      { "month": "May", "value": 32000 }
    ]
  }
}

Then wrap in the artifact template from assets/template.html.

Files

  • assets/template.html — Complete artifact template with embedded renderer
  • assets/catalog.json — Machine-readable component schemas
  • references/uitree-format.md — Detailed UITree specification

Source

git clone https://github.com/oaustegard/claude-skills/blob/main/json-render-ui/SKILL.mdView on GitHub

Overview

Turns natural language UI requests into working dashboards and apps using a guardrailed UITree. Claude translates prompts into constrained JSON, and the skill runtime renders that UITree to UI via a Preact-based renderer. This approach supports dashboards with metrics, charts, and tables, admin panels, data visualizations, and form-style interfaces.

How This Skill Works

User describes the desired UI in natural language. Claude converts the description into a UITree JSON that adheres to the allowed components, then the runtime renders the UI with a Preact renderer. Data binding uses JSON Pointer paths (e.g., /revenue -> data.revenue) to connect UI elements to the data model.

When to Use It

  • Generate dashboards with metrics, charts, and tables from a JSON-specified UI
  • Build admin panels for users, roles, and settings
  • Create data visualization interfaces (charts, lists) driven by a data model
  • Prototype form-based applications using Select, DatePicker, and Buttons
  • Iterate quickly by describing UI changes in NL and rendering guarded UITree

Quick Start

  1. Step 1: Describe the UI you want in natural language or supply a target data model.
  2. Step 2: The skill translates it into a constrained UITree JSON using allowed components.
  3. Step 3: The Preact renderer renders the UI and binds data with JSON Pointer paths.

Best Practices

  • Describe UI using only catalog components (Card, Grid, Metric, Chart, Table, List, Button, Select, DatePicker, Heading, Text, Badge, Alert, Divider, Empty).
  • Prefer Grid for layout and Stack for simple vertical stacking to maintain predictable layouts.
  • Use data bindings with JSON Pointer syntax (dataPath/valuePath) to connect to the data model.
  • Provide clear labels, titles, and formats (currency, percent, date) to improve readability.
  • Validate the UITree against the catalog and test rendering with sample data before deployment.

Example Use Cases

  • Revenue dashboard showing Revenue (currency) and Growth (percent) metrics plus a line Chart and a Table of top products.
  • User admin panel with a Card header, a Grid of metrics, and a Table listing users.
  • Product analytics dashboard with a Bar Chart for sales by category and a List of top SKUs.
  • Form-like UI for data entry using Select controls and a DatePicker to capture selections.
  • Empty state example using the Empty component when no results are available.

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers