Schema Format
Component type definition syntax and structure
Schema Format
Component types use a structured MDX format with frontmatter sections for metadata, props, parts, and CSS variables.
File Structure
Metadata Fields
| Field | Required | Description |
|---|---|---|
$type | Yes | Always https://mdx.org.ai/ComponentSpec |
$id | Yes | Unique URI identifier |
name | Yes | Component name (PascalCase) |
category | Yes | Component category |
description | Yes | Brief description |
semanticElement | No | Primary HTML element |
outputs | No | Supported output formats |
related | No | Related component names |
Props Section
Props use ai-functions schema syntax - a concise format for defining typed properties.
Basic Syntax
Types
| Syntax | TypeScript Equivalent | Example |
|---|---|---|
string | string | title: string |
number | number | columns: number |
boolean | boolean | sticky: boolean |
Type[] | Type[] | items: Feature[] |
Type? | Type | undefined | subtitle: string? |
'a' | 'b' | 'a' | 'b' | layout: 'grid' | 'list' |
Optional Props
Append ? to make a prop optional:
Default Values
Use = value to specify defaults:
Complex Types
Reference other types by name:
Union Types
Use | for enum-like values:
Parts Section
Parts define semantic CSS slots - named regions of the component that can be styled.
Basic Syntax
Examples
Naming Conventions
- Use kebab-case for multi-word parts:
header-title,nav-item - Prefix nested parts with parent:
header-title(title inside header) - Mark optional parts with
?
Semantic Elements
Choose elements that convey meaning:
| Element | Use For |
|---|---|
header | Component header sections |
footer | Component footer sections |
nav | Navigation containers |
section | Thematic groupings |
article | Self-contained content |
aside | Sidebar/supplementary content |
main | Primary content |
div | Generic containers |
h1-h6 | Headings |
p | Paragraphs |
a | Links |
button | Interactive buttons |
img | Images |
form | Forms |
input | Form inputs |
CSS Variables Section
CSS variables define theming customization points.
Basic Syntax
Examples
Naming Conventions
- Prefix with component name:
--hero-,--card-,--nav- - Use descriptive suffixes:
-padding,-margin,-size,-color,-bg - Reference design tokens:
var(--color-primary)
Common Patterns
JSON-LD Mapping
For Thing components (Person, Product, Organization, Article), map props to Schema.org:
This enables automatic generation of structured data for SEO.
Documentation Content
After the frontmatter, include markdown documentation:
┌─────────────────────────────────────┐ │ root │ │ ┌─────────────────────────────────┐ │ │ │ header │ │ │ │ title │ │ │ └─────────────────────────────────┘ │ │ ┌─────────────────────────────────┐ │ │ │ content │ │ │ └─────────────────────────────────┘ │ └─────────────────────────────────────┘
Variants
Document layout/style variants...