Skip to content

Core concepts

A micro-app is one JSON document. Its heart is a json-render spec: a root key and a flat map of elements, where each element has a type, props and a list of children keys. The document is authoritative — the canvas is simply json-render’s Renderer drawing it, and every edit you make is a JSON patch applied to it. Undo and redo step through those patches; edits to the same property in quick succession (within 900 ms) merge into one undo step.

Mica exports the document inside a versioned envelope that keeps the spec under ui next to Mica’s own data. See the document format.

A pack is a curated component vocabulary with its own default theme, starter template and React visuals. A document is bound to one pack by meta.pack, and import refuses a document whose pack or pack version this build of Mica does not provide. Two packs ship today:

  • Signal (mica.core) — crisp operational surfaces with citrus accents and practical controls, including the form controls Input, NumberField, Choice, Toggle, DateField, DateRange and Slider.
  • Nocturne (mica.nocturne) — cinematic editorial pages with serif scale, sharp rules, pull quotes and dividers.

Both share the structural components PageStack, Page, Stack, Grid and Spacer. Documents cannot be converted from one pack to another. The components reference lists every component and prop.

Each pack renders with its default theme. A host can pass its own theme instead, built from a brand colour, fonts and a corner radius. A theme changes how a document looks, never what it contains, and a document never names one.

The root element is always a PageStack, and its children are all Page elements. Only one page shows at a time. Which one is never document state: in the designer it is the page tab you have open; in the preview it is preview-local; in a host it is whatever key the host passes to PageProvider. Buttons move between pages with the goToPage action, which a host receives as a navigation intent. With no key, the first page shows.

A document can seed state — plain JSON values under ui.state such as { "guest": { "name": "" } }. State is addressed with JSON Pointers like /guest/name. At runtime, state lives in a store the host creates; writes from buttons and inputs change that store, never the document itself. /mica/… is reserved for hosts, and documents may not read or write it.

Some props accept an expression object instead of a literal:

Expression Meaning Where
{ "$state": "/path" } Read a state value Text and Heading content; Signal form controls’ writable
{ "$bindState": "/path" } Read and write a state value Signal form controls’ value (a DateRange’s start and end)
{ "$cond": <condition>, "$then": true, "$else": false } A condition evaluated on every render Signal form controls’ required; Button disabled and busy
{ "$format": … } Show a raw value as money, a date or a count Text and Heading content, Value value
{ "$calc": … } Display-only calculation The same display props as $format, and as a $format’s value
{ "$expr": … } Typed formula A number or text formula in those display props; a boolean formula as the whole visible, $cond or requiredWhen

See bindings and conditions for every expression and the props that accept it; anywhere else a $-key is refused.

A condition is { "$state": "/path" } (truthy) or { "$state": "/path", "eq": value } with at most one comparison — eq, neq, gt, gte, lt or lte — and optionally "not": true to invert it, a list of such parts that must all hold, or { "$or": [group, …] }, which holds when any group does (each group one part or a list of parts). The same grammar serves an element’s visible, a $cond prop, and a business object input’s requiredWhen. A boolean $expr may be the whole condition — not mixed into an All of / Any of list.

Eight components fire an event: a Button’s press, when a person presses it; an Input’s commit, when a person presses Enter in it (a text area’s never), or leaves it after changing its value (a DateField’s or DateRange’s typed date too, and a date picked from their calendar at once); a NumberField’s, Choice’s or Toggle’s commit, on each change a person makes; and a Slider’s, when a drag or key press ends on a new value. An element’s on maps its event to one action binding or a list of up to eight, run in order. Only a person raises an event — a state write never does. The vocabulary is closed:

  • setState writes a literal or a copied state value to a path.
  • goToPage asks the host to show another page.
  • fetch, create, update and delete act on a declared business object.

A host may register handlers for other action names — the reference host does — but the designer’s importer only accepts these six. See the actions reference.

A document may declare a business object it expects a host to provide: an alias such as customer, a host type key such as crm.customer, an identity field, the fields it reads, and the capabilities it uses (fetch, create, update, delete) with their typed inputs. The runtime projects the current record and its lifecycle into ordinary state:

  • /objects/{alias}/data — the current record, only its declared fields.
  • /meta/objects/{alias}/operations/{operation}/phase — idle, loading, success or error, and …/error beside it.
  • /meta/objects/{alias}/capabilities/{operation} — whether the host implements and allows it.
  • /meta/objects/{alias}/fields/{field} — whether the signed-in person may edit that field.

Because these are ordinary state paths, the same $state reads and visible conditions work on them. Documents may read them but never write them. See declare a business object.

Designer canvas Designer preview Host runtime
visible conditions Ignored, so everything stays selectable Applied Applied
State Document state + design samples Disposable copy of both The host’s store
Business objects Design sample Mock host: samples + sidecar fixtures The host’s implementation
lifecycle.startup Not run Run against the mock Run once by runStartup()
Capabilities Reported not implemented Declared verbs implemented in the mock Whatever the host reports

The designer never contacts a live host. A design sample is authoring material only, and an embedded host never shows it as live data. Preview plays those samples (and sidecar fixtures) so Save and fetch-on-start can be seen offline.