Generating UI from natural language is powerful but fragile. If the model outputs a component name your renderer doesn’t support, a field name with spaces, or 50 form fields for a simple request, your frontend either crashes or renders garbage. A strict schema turns the model’s output into a guaranteed-renderable form spec: known component types, valid field names, bounded counts. The key insight is that your schema should mirror what your renderer actually accepts. If your React form builder supports six component types, the schema’sDocumentation Index
Fetch the complete documentation index at: https://docs.dottxt.ai/llms.txt
Use this file to discover all available pages before exploring further.
component enum should list exactly those six. If your layout engine supports single and two-column modes, the schema should enumerate those. The model generates within these bounds, and the output is always renderable.
Goal
Convert product requests into a form specification that a React frontend can render directly without validation or transformation.Recommended contract
Prompt pattern
Example input
Example output
Implementation tips
- Component enum mirrors your renderer. If your form builder gains a new component type (e.g.,
date_picker), add it to the schema enum. If the model suggests a type not in the enum, the schema rejects it at generation time. - Conditional requirements prevent incomplete specs. The
allOfblock requiresoptionswhencomponentis"select". Without this, the model might produce a select field with no options: valid JSON, but unrenderable. - Bounds protect layout.
maxItems: 20on fields prevents the model from generating overwhelming forms.maxLengthon labels and placeholders keeps text from breaking your CSS grid. - Field name pattern keeps keys predictable. The
"^[a-z][a-z0-9_]*$"pattern onnameenforces lowercase snake_case field keys, which keeps form state and backend mappings consistent without extra normalization.
Related docs
- Conditional requirements: require
optionsonly whencomponentis"select", and similar patterns - Unions of objects: discriminated unions for different component types
- Object reference | Conditionals reference | String reference