UI Spec
Reference for the UI Spec format — document structure, fields, and validation rules.
This page describes the structure of a UI Spec document. For methodology and workflows, see How It Works. For advanced techniques, see Patterns & Practices.
Public format file: ui-spec-format-0-0-3.yaml
Document Root
A UI Spec document is a YAML file with the following top-level fields.
| Field | Type | Required | Description |
|---|---|---|---|
docType | string | yes | Always ui-spec |
format_version | string | yes | Format version (e.g., "0.0.3") |
metadata | object | yes | Document metadata |
templates | object | no | Reusable page layout templates |
default_template | string | no | Template ID applied to screens without an explicit template |
navigation | object | no | Navigation structure between screens |
screen_groups | array | no | Grouping for specs with many screens |
screens | object | yes | Screen definitions (the core of the spec) |
Metadata
The metadata object describes the application and its visual style.
| Field | Type | Required | Description |
|---|---|---|---|
name | string | yes | Technical name of the spec |
description | string | yes | What the application does (1–3 sentences). This is the key field for AI — it is included in implementation prompts instead of name |
theme | string | no | Visual theme (e.g., "modern minimal", "glassmorphism with soft shadows") |
background | string | no | Background description (e.g., "gradient blue to purple") |
palette | object | no | Named color semantics — text descriptions, not hex codes (e.g., {primary: "soft blue gradient", accent: "warm orange"}) |
breakpoints | object | no | Custom breakpoints. Defaults: mobile: "< 768px", tablet: "768px - 1023px", desktop: ">= 1024px" |
Templates
Templates define reusable page layouts with named regions. Define templates when multiple screens share the same structure (e.g., header + sidebar + content).
Each template is defined under templates with a unique ID (snake_case).
| Field | Type | Required | Description |
|---|---|---|---|
purpose | string | yes | Template description (10+ characters) |
regions | array | yes | List of regions. Must contain at least one region and exactly one with type: content |
Region
| Field | Type | Required | Description |
|---|---|---|---|
id | string | yes | Unique within the template |
type | string | yes | static, content, or floating |
position | string | yes | For static/content: left, right, top, bottom, center. For floating: top-left, top-right, bottom-left, bottom-right, center |
fullHeight | boolean | no | For left/right regions — span full height |
fixed | boolean | no | Sticky/fixed positioning (static regions only) |
purpose | string | no | Region description |
blocks | array | no | Blocks inside the region (static and floating only — not content) |
Navigation
The navigation object defines links between screens.
| Field | Type | Required | Description |
|---|---|---|---|
items | array | yes | List of navigation items |
Navigation Item
| Field | Type | Required | Description |
|---|---|---|---|
id | string | yes | Unique identifier |
label | string | yes | Display label |
target | string | yes | Target screen_id (must exist in screens) |
Screen Groups
Optional grouping for specs with many screens. Recommended when a spec has more than 15 screens.
Each group is an object in the screen_groups array.
| Field | Type | Required | Description |
|---|---|---|---|
id | string | yes | Group ID (snake_case, displayed as title) |
screens | array | yes | List of screen_id values belonging to this group |
Screens not assigned to any group appear in an "Other" section.
Screens
Screens are defined under the screens object. Each key is a unique screen_id (snake_case).
| Field | Type | Required | Description |
|---|---|---|---|
title | string | yes | Screen title |
purpose | string | yes | Screen description (10+ characters) |
template | string or object | no | Template ID, or an object with breakpoint-specific templates: {default: "...", mobile: "...", tablet: "...", desktop: "..."} |
container_max_width | string | no | Max width of the content area (e.g., "800px", "100%", "90vw") |
blocks | array | no | List of blocks on this screen |
Blocks
Blocks are the core building units of a screen. Each block describes a logical piece of the interface through its purpose.
| Field | Type | Required | Description |
|---|---|---|---|
id | string | yes | Unique within the screen (snake_case) |
purpose | string | yes | What the block shows and how it behaves |
columns | integer or object | no | Width in a 12-column grid (default: 12). Can be an object for adaptive layout: {default: 3, tablet: 4, mobile: 12} |
visible | string, array, or object | no | Breakpoint visibility. If omitted, the block is visible everywhere. Examples: "desktop", [desktop, tablet], {show: [desktop, tablet], hide: [mobile]} |
blocks | array | no | Nested child blocks (same structure, recursive) |
Purpose
The purpose field is the most important field in the format. It describes intent, not implementation — what the block should show, what data it displays, and how it behaves. This includes interactions (click opens a modal, hover reveals actions), state variations (empty state, loading state, error state), and relationships between blocks (selecting an item in one block updates another). AI agents both generate and interpret these descriptions semantically.
Always use double quotes for purpose values in YAML.
# Good — describes intent and appearance:
purpose: "Four metric cards showing total, completed, in progress, and overdue tasks"
# Good — describes behavior:
purpose: "Button 'New Task', onClick opens modal_create_task"
# Good — describes state variations:
purpose: "Task list with status filters. Empty state: 'No tasks yet' with create button"
# Too implementation-specific:
purpose: "div with display:grid, grid-template-columns: repeat(4, 1fr), gap: 16px"For detailed guidance on writing purposes — progressive precision levels, behavioral patterns, and nested structure strategies — see Patterns & Practices.
Nesting
Blocks can be nested to any depth. Child blocks inherit the visible property from their parent.
blocks:
- id: user_profile
purpose: "User profile card"
blocks:
- id: avatar
purpose: "Circular user photo, clickable"
- id: info
purpose: "Name and bio"
blocks:
- id: name
purpose: "User name, bold"
- id: bio
purpose: "Short bio, max 3 lines"Grid Layout
Blocks use a 12-column grid system (similar to Bootstrap). The columns field defines how many columns a block occupies.
| Columns | Width | Common use |
|---|---|---|
| 12 | 100% | Full width |
| 6 | 50% | Half |
| 4 | 33% | Third |
| 3 | 25% | Quarter |
When the sum of columns in a row exceeds 12, blocks wrap to the next row. On mobile, blocks typically become full-width unless adaptive columns are specified.
Detailing Levels
The format supports progressive precision. You choose how much detail to include based on your needs.
Exploration (L0). Screens with titles and purposes. No blocks, no theme. Enough to discover what screens the app needs.
screens:
dashboard:
title: Dashboard
purpose: "Overview of user tasks and productivity"Structure (L1). Add blocks with purposes and basic columns. Optionally add theme.
screens:
dashboard:
title: Dashboard
purpose: "Overview of user tasks and productivity"
blocks:
- id: stats
columns: 12
purpose: "Key metrics: total notes, active drafts, archived"Detailed (L2). Add palette, templates, navigation, detailed purposes, nested blocks.
Full Control (L3). Add exact sizes, spacing, animations, transitions in purpose text. Implementation-ready.
Different screens in the same spec can use different detail levels. For examples and guidance, see Patterns & Practices.
Common Patterns
Typical screen structures used in specs.
| Pattern | Structure |
|---|---|
| List screen | Header (actions, filters) + content (table or grid) |
| Detail screen | Info sections + sidebar (actions, stats, related) |
| Form screen | Form sections + footer (save / cancel) |
| Dashboard | Header (title, actions) + widgets in columns |
| Wizard | Header (steps) + current step content + footer (back / next / finish) |
Overlay Patterns
Overlays are described as blocks with specific purpose patterns.
| Pattern | Purpose example |
|---|---|
| Modal | "Modal dialog 'Create Task' (centered overlay). Form with fields, Cancel/Submit buttons" |
| Drawer | "Drawer panel (slides from right). Content, Apply/Reset buttons" |
| Confirmation | "Modal dialog 'Confirm' (centered overlay). Warning text, Cancel/Confirm" |
| Popover | "Popover menu (appears near trigger). Menu items list" |
| Toast | "Toast notification (top-right). Message, auto-dismiss" |
| Trigger | "Button 'Create', onClick opens modal_id" |
Validation Rules
Key rules that a valid UI Spec must follow.
Structure: Each template must have at least one region and exactly one with type: content. Block IDs must be unique within their screen. Region IDs must be unique within their template.
References: default_template, screen.template, navigation.items[].target, and screen_groups[].screens[] must reference existing IDs. Missing references are errors.
Layout: Column values must be 1–12. Sum exceeding 12 wraps to a new row.
Responsive: template can be a string or an object with default (required) and optional mobile, tablet, desktop. Same for columns. The visible field accepts a string, array, or object with show/hide arrays.
Formatting: Always use double quotes for string values containing special characters (: { } [ ] , & * # ? | - < > = ! % @ \).