Pages and navigation
Every document is a PageStack whose children are Page elements. One page
shows at a time, and buttons move between them.
Add, rename and remove pages
Section titled “Add, rename and remove pages”- Add page beside the page tabs appends a page titled Page N and selects
it. Its element key is generated from the type —
page-1,page-2, … — and never changes afterwards. - Click a page tab to open that page and select the
Pageelement. Its Title is the label on the tab (and in a host’s own page switcher, if it shows one); Background ispaper,mistorink. - The × on the open tab removes that page and everything on it. A document
always keeps at least one page. Removing a page also removes every
goToPageaction that pointed at it, and its key from everyStepselement’s Counted pages, in the same undoable step, so no button is left pointing nowhere.
Which page the designer shows is editor state. It is not saved in the document, and the first page is what a host shows when it does not ask for another.
Navigate with a button
Section titled “Navigate with a button”Select a Button, press Add action in its Events section, and change the action to Go to page. The page list shows each page as Title (key). The document stores the key:
"on": { "press": { "action": "goToPage", "params": { "page": "page-thanks" } } }Import refuses a goToPage whose page is not a child of the root PageStack.
Actions in one event run in order, so a button can record something and then move on:
"on": { "press": [ { "action": "setState", "params": { "statePath": "/guest/attending", "value": true } }, { "action": "goToPage", "params": { "page": "page-thanks" } } ]}If an earlier action fails — for example a business-object create the host
rejects — the rest of the event does not run, so the person stays on the page
where the error is shown. The support ticket and
purchase approval examples rely on this.
Show the step a person is on
Section titled “Show the step a person is on”A Steps element shows a wizard’s “Step 2 of 3” without typing the numbers:
it reads which page is showing and counts the pages, so removing or
reordering a page needs no edits, and neither does adding one while every
page counts. Drag Steps from the palette onto each
step page. Its Format is the text it shows, where {n} is the page’s
position and {total} the number of pages it counts; any other {…} is
refused.
By default it counts every page. When the flow has pages that are not steps,
such as a done page, tick the step pages under Counted pages: {n} and
{total} then count only those, in page order whatever order pages lists
them in, and on any other page the element shows nothing. A new step page
must be ticked on each Steps. Import refuses a key there that is not a page.
"name-steps": { "type": "Steps", "props": { "format": "Step {n} of {total}", "pages": ["page-name", "page-team", "page-check"] }, "children": []}This three-step sign-up ends on a done page that is not counted. Its check
page shows each answer in a Value, the team’s
through $label so it reads as the option’s label:
How navigation reaches a host
Section titled “How navigation reaches a host”Mica never reads or writes a URL. When a goToPage action runs, the runtime
hands the target key to the host’s onNavigate callback, and the host decides
what that means — a hash route, a tab, a history entry. The host then renders
the page it wants by passing its key to PageProvider. An unknown key renders
an in-place message naming the valid keys instead of crashing.
See Embed Mica in a host application for the code.
The designer’s Map → Pages view draws each page and its goToPage edges.
Positions are stored in the sidecar, not the document — see
Explore the data and page maps.
Pages cannot be hidden
Section titled “Pages cannot be hidden”visible is refused on the PageStack and on pages: pages are selected by
navigation, and a hidden page would leave nothing on screen. The Show when
builder is not offered for them.