To address your requirements, here's a structured JSON output format designed for flexibility, customizability, and cross-platform compatibility. This format decouples layout/styling from view-layer specifics (e.g., HTML/CSS) while enabling hierarchical design tokens and predictable parsing.
Core Principles
- Abstract Layout System: Uses generic terms like
stack, zone, and flow instead of HTML-specific primitives.
- Token Hierarchy: Three-tiered design tokens (primitive → system → component) for scalable styling.
- Component-Driven Structure: Self-contained components with explicit property contracts.
- Schema-First Design: Enforced via JSON Schema to ensure LLM predictability.
JSON Output Structure
{
"page": {
"metadata": {
"title": "Example Page",
"description": "A dynamically generated landing page"
},
"tokens": {
"primitives": {
"colorPrimary": "#0000FF",
"fontFamilyBase": "Arial",
"spacingUnit": "16px"
},
"system": {
"primaryColor": "{primitives.colorPrimary}",
"buttonPadding": "{spacingUnit * 2}"
},
"components": {
"headerTextColor": "{system.primaryColor}",
"buttonStyle": {
"padding": "{system.buttonPadding}",
"borderRadius": "8px"
}
}
},
"layout": {
"id": "root",
"type": "stack",
"direction": "vertical",
"align": "center",
"children": [
{
"id": "header-section",
"type": "component",
"componentType": "text",
"content": {
"text": "Welcome to Our Site",
"variant": "h1"
},
"style": {
"color": "{components.headerTextColor}",
"fontSize": "{system.spacingUnit * 2}"
}
},
{
"id": "features-grid",
"type": "grid",
"columns": 3,
"gap": "{spacingUnit}",
"children": [
{
"id": "feature-1",
"type": "component",
"componentType": "card",
"content": {
"title": "Feature 1",
"body": "Description of feature 1."
},
"style": {
"backgroundColor": "{primitives.colorPrimary}33"
}
}
]
}
]
}
}
}
Key Components Explained
1. Layout System
- Container Types:
stack: Horizontal/vertical flex-like layout ().