Skip to content

Build your first micro-app

In this walkthrough you build a team lunch RSVP: a page where a colleague enters their name and dietary needs, and a thank-you page that repeats what they entered. Along the way you use every basic Mica tool — layout, properties, document state, two-way binding, button events, page navigation, conditional visibility, preview and export. It takes about fifteen minutes.

This is the finished micro-app, running live through mica/runtime. Type a name, press Count me in, and watch the state panel:

Open the designer in a new tab (contributors can also run it from the repository; see Run the designer). The screenshots on this page show the stored copy of the finished document, whose element keys are descriptive — you will see page-thanks where your own document says page-1.

  1. On the pack picker, choose Start with Signal. Mica opens Signal’s two-page starter template, Northstar Dispatch.

  2. Click an empty part of the grey canvas around the page. The inspector on the right now shows the Page stack — the root of every document. Change its Name to Team lunch RSVP. The top bar picks up the new name.

  3. The starter content is only there to show what the pack can do. Select the Team page tab and press the × beside it to remove the page.

  4. On the Overview page, hover each top-level block (the hero, the metrics grid, the In motion section, the spacer and the closing section) and press the trash icon in its hover toolbar. Deleting a container deletes everything inside it. Every deletion is one undoable step (⌘Z).

  5. Click the Overview tab to select the page itself. In the inspector set Title to RSVP and Background to Mist. The title is what the page tab shows; the page keeps its key (page-overview), which is how buttons refer to it.

  1. Drag a Section from the palette onto the empty page and drop it on the highlighted Drop here area. In the inspector, set Eyebrow to FRIDAY · 12:30, Title to Friday team lunch and Tone to Raised.

  2. Drag a Text into the centre of the section to nest it inside. Set its content to Tell us you're coming so we order enough food. and its Tone to Muted.

  3. Drag two Input components below the text, then a Button below them. Aim at a component’s top or bottom edge to drop before or after it — a line shows where it will land.

  4. Select the first Input and set Label to Your name, Placeholder to Full name, Input Type to Text, and switch Required on. Set the second Input’s label to Dietary needs and its placeholder to Vegetarian, allergies, …, set its type to Text, and give it the help text Optional.

  5. Select the Button and set Label to Count me in.

The RSVP page on the canvas, with the Page stack selected in the inspector.

A micro-app remembers what the person has entered in document state: named values the app starts with and that buttons and inputs can change.

  1. Switch the inspector to the State tab (top right) and keep the Values view.

  2. In the new key box type guest/name, leave the value empty, and press Add. A / in a key nests it, so this creates /guest/name holding an empty text value.

  3. Add guest/diet the same way, then guest/attending with the value false. The panel now shows one /guest row holding all three values.

The State tab with the /guest values the app starts with.

  1. Switch back to the Component tab and select the Your name Input.

  2. Under Value, choose $bindState and pick /guest/name from the suggestions. The Input now reads and writes that path: whatever the person types is stored there while the app runs.

  3. Bind the Dietary needs Input to /guest/diet the same way.

The Input’s Value bound two-way to /guest/name.

  1. Press Add page beside the page tabs. Mica adds Page 2 with the key page-1 and selects it. Set its Title to Thanks.

  2. Drag a Heading, two Text components and a Button onto the page. Set the heading content to See you on Friday, level 1, and switch Accent on to highlight its last word. Set the button label to Change my answer and its variant to Outline.

  3. Select the first Text. Under Content, choose State and enter /guest/name, and set Size to Lg. The text now shows whatever is stored at that path.

  4. Bind the second Text’s content to /guest/diet and set its tone to Muted.

6. Show a line only when it has something to say

Section titled “6. Show a line only when it has something to say”

Not everyone has dietary needs, so the second line should only appear when /guest/diet holds something.

  1. With the diet Text selected, find Show when and press Add condition.

  2. Enter /guest/diet as the state path and leave the operator on is truthy. An empty text value is not truthy, so the line stays hidden until the person types something.

The Show when builder on the diet Text.

The canvas keeps showing every component so you can still select it; conditions take effect in the preview and at runtime.

  1. Go back to the RSVP page and select Count me in. The inspector shows an Events section: what happens when the button is pressed.

  2. Press Add action. The new row is Set a value: enter /guest/attending as the state path and true as the value.

  3. Press Add action again and change the new row to Go to page, then pick Thanks (page-1). Actions run in order, top to bottom.

  4. On the Thanks page, select Change my answer, add one action, change it to Go to page, and pick RSVP (page-overview).

The Events section: set a value, then go to the Thanks page.

  1. Press Preview in the top bar. The document now runs for real in a disposable session seeded from its state.

  2. Type a name and a dietary need, then press Count me in. The page switches to Thanks and shows what you typed. The Event log on the right records each action with the state it changed.

  3. Press Reset preview to start the session again from the document’s state, or Exit preview (or Esc) to go back to editing. Nothing you did in the preview is saved into the document or its undo history.

The preview after pressing Count me in: the Thanks page and the event log.

  1. Press Export JSON. Mica downloads team-lunch-rsvp.json — the whole micro-app as one versioned document.

  2. Press Import, paste a document into the dialog and press Replace document to open it. Import validates everything: a document with an unknown component, a misspelled prop or a button pointing at a missing page is refused with a message naming the problem, and nothing is lost quietly.

The document you built matches the one below, which is stored in the repository. The only difference is the element keys: the designer names new elements after their type (section-1, input-2, …), while the stored copy uses descriptive keys such as rsvp-name so it is easier to read.

Complete document — examples/documents/first-app.json
examples/documents/first-app.json
{
"envelopeVersion": 1,
"ui": {
"root": "app",
"elements": {
"app": {
"type": "PageStack",
"props": {
"name": "Team lunch RSVP"
},
"children": [
"page-rsvp",
"page-thanks"
]
},
"page-rsvp": {
"type": "Page",
"props": {
"title": "RSVP",
"background": "mist"
},
"children": [
"rsvp-card"
]
},
"rsvp-card": {
"type": "Section",
"props": {
"eyebrow": "FRIDAY · 12:30",
"title": "Friday team lunch",
"tone": "raised",
"padding": "lg"
},
"children": [
"rsvp-intro",
"rsvp-name",
"rsvp-diet",
"rsvp-submit"
]
},
"rsvp-intro": {
"type": "Text",
"props": {
"content": "Tell us you're coming so we order enough food.",
"size": "md",
"tone": "muted",
"align": "left",
"italic": false
},
"children": []
},
"rsvp-name": {
"type": "Input",
"props": {
"label": "Your name",
"placeholder": "Full name",
"inputType": "text",
"required": true,
"helpText": null,
"value": {
"$bindState": "/guest/name"
}
},
"children": []
},
"rsvp-diet": {
"type": "Input",
"props": {
"label": "Dietary needs",
"placeholder": "Vegetarian, allergies, …",
"inputType": "text",
"required": false,
"helpText": "Optional",
"value": {
"$bindState": "/guest/diet"
}
},
"children": []
},
"rsvp-submit": {
"type": "Button",
"props": {
"label": "Count me in",
"variant": "solid",
"size": "md",
"disabled": false,
"fullWidth": false
},
"children": [],
"on": {
"press": [
{
"action": "setState",
"params": {
"statePath": "/guest/attending",
"value": true
}
},
{
"action": "goToPage",
"params": {
"page": "page-thanks"
}
}
]
}
},
"page-thanks": {
"type": "Page",
"props": {
"title": "Thanks",
"background": "paper"
},
"children": [
"thanks-heading",
"thanks-name",
"thanks-diet",
"thanks-back"
]
},
"thanks-heading": {
"type": "Heading",
"props": {
"content": "See you on Friday",
"level": "1",
"align": "left",
"accent": true
},
"children": []
},
"thanks-name": {
"type": "Text",
"props": {
"content": {
"$state": "/guest/name"
},
"size": "lg",
"tone": "default",
"align": "left",
"italic": false
},
"children": []
},
"thanks-diet": {
"type": "Text",
"props": {
"content": {
"$state": "/guest/diet"
},
"size": "md",
"tone": "muted",
"align": "left",
"italic": false
},
"children": [],
"visible": {
"$state": "/guest/diet"
}
},
"thanks-back": {
"type": "Button",
"props": {
"label": "Change my answer",
"variant": "outline",
"size": "md",
"disabled": false,
"fullWidth": false
},
"children": [],
"on": {
"press": {
"action": "goToPage",
"params": {
"page": "page-rsvp"
}
}
}
}
},
"state": {
"guest": {
"name": "",
"diet": "",
"attending": false
}
}
},
"meta": {
"pack": {
"id": "mica.core",
"version": "1.0.0"
}
}
}