MetabindUI Inspector Grammar with Zod Compatibility
Overview
Theinspector function defines component properties for both UI editing controls and type validation. This grammar is compatible with Zod schemas and can be used to auto-generate TypeScript types.
Basic Structure
Mapping to Zod
Property Types
| Type | UI Control | Zod Equivalent |
|---|---|---|
| string | Text input | z.string() |
| number | Number input | z.number() |
| boolean | Toggle | z.boolean() |
| color | Color picker | z.string().regex(/^#/)) |
| enum | Dropdown | z.enum([...]) |
| json | JSON editor | z.any() |
| array | List | z.array(...) |
| object | Object editor | z.object({...}) |
| asset | Media browser | z.string() or z.array(z.string()) |
| components | Component list | z.array(...) |
Common Fields
All property types may include:title: Human-readable namedescription: Description or tooltipdefault: Default valuerequired: Whether the field is mandatoryhidden: Hide from UI editordeprecated: Mark as deprecated with optional messagegroup: Group for UI organizationcondition: Conditional display rule{ key, eq }
Type-Specific Fields
String
Number
Boolean
Color
Enum
JSON
Array
Object
Advanced Features
Conditional Properties
Asset
Custom Controls
Computed Defaults
TypeScript Type Generation
Best Practices
- Use descriptive
titleanddescription. - Group related properties with
group. - Set sensible
defaultvalues. - Use
conditionto improve UI relevance. - Avoid unused fields.
- Maintain property declaration order.
- Favor predictable, flat object shapes.
- Avoid optional fields unless semantically needed.
