Skip to main content

MetabindUI Inspector Grammar with Zod Compatibility

Overview

The inspector 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

TypeUI ControlZod Equivalent
stringText inputz.string()
numberNumber inputz.number()
booleanTogglez.boolean()
colorColor pickerz.string().regex(/^#/))
enumDropdownz.enum([...])
jsonJSON editorz.any()
arrayListz.array(...)
objectObject editorz.object({...})
assetMedia browserz.string() or z.array(z.string())
componentsComponent listz.array(...)

Common Fields

All property types may include:
  • title: Human-readable name
  • description: Description or tooltip
  • default: Default value
  • required: Whether the field is mandatory
  • hidden: Hide from UI editor
  • deprecated: Mark as deprecated with optional message
  • group: Group for UI organization
  • condition: 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

  1. Use descriptive title and description.
  2. Group related properties with group.
  3. Set sensible default values.
  4. Use condition to improve UI relevance.
  5. Avoid unused fields.
  6. Maintain property declaration order.
  7. Favor predictable, flat object shapes.
  8. Avoid optional fields unless semantically needed.