Twenty recipes
On this page
- 1. A list with empty, loading and failed states
- 2. A form with field errors
- 3. A dialog
- 4. A bottom sheet
- 5. A confirmation before something destructive
- 6. A floating create button
- 7. Tabs kept in the address
- 8. Show or hide by data
- 9. A bound icon
- 10. A leave guard
- 11. Search
- 12. A page only a signed-in person sees
- 13. Who may do what on an operation
- 14. A new entity and its migration
- 15. A background job or flow
- 16. A notice (snackbar)
- 17. An upload
- 18. Dark mode and brand colours
- 19. A new page from a template
- 20. A stage site on the internet
Each recipe is the shortest way found to do one thing, as a tool call (for an agent) or studio steps, then where Rally does it. "Run" means it was run in a scratch project built from Tutorial 1 (the design is my-first-app, the page Things); "Not run" says so. <id> is a node id from get_page({ design, page, format: "outline" }). After any change: npx globetrotter sync, then npx globetrotter doctor. Tool names are the globetrotter-design MCP tools (06 installs them); every tool call here has a studio equivalent unless said.
1. A list with empty, loading and failed states
A list is a List whose ListItem has repeat: <collection>. Give the page three siblings: LoadingRows with whenLoading: true, an EmptyState with whenEmpty: "<collection>", a Banner with whenError: "<collection>".
Run: a new project's Items page already has all three. A page that lacks one is told by lint list-waits-blank; apply_fix({ design, page, rule: "list-waits-blank" }) adds it.
Or start from add_page({ design, name: "Guests", template: "list-detail", reads: "Things.list" }) (reads names the service query as Service.query; a bare name was refused: "Guests is no Query of a service that lists rows: name it as Service.query, like Products.list").
Studio: the state bar above the canvas (Loaded / Loading / Empty / Failed) shows each state without breaking anything.
Rally: the Games page (frontend/src/bindings/rally--games.ts, useRead returns status, error, reload).
2. A form with field errors
The sentence is written once, in the service, on the param and the field: set_service_props({ design, node: "item-title", props: { max: 80, message: "Say what to bring." } }) and the same on the create's param (items-create-title). The page's TextField has field: "draft.title"; a 400 that names title puts the words under that input (Tutorial 1, step 6).
Studio: Backend → Entities, click the field, When it is wrong, Review the change, Save.
Rally: frontend/src/bindings/rally--setup-about.ts; each binding's inputOf table maps a param to the page's input.
3. A dialog
add_node a Dialog (target { kind: "content" }, props title), its words in slot children, its buttons in slot actions, then a Button with opens: "<the Dialog's id>". Cancel and a plain button close it.
Run: Tutorial 1 ("Packing tip").
Rally: the Games page's "Your sports" dialog.
4. A bottom sheet
Same as a dialog with type: "BottomSheet" (props title, handle, closes): it rises from the bottom, pulls down by its handle.
add_node({ design, page, target: { kind: "content" }, type: "BottomSheet", props: { title: "Share the list" } })
add_node({ design, page, target: { kind: "slot", parentId: "<sheet id>", slot: "children" }, type: "Text", props: { text: "Send the link." } })
add_node({ design, page, target: { kind: "content" }, type: "Button", props: { text: "Share", opens: "<sheet id>" } })Run. Rally: Tournament run ("Add players", "Swap in or cancel", "Who did not come?").
5. A confirmation before something destructive
Add the button that removes (text: "Remove everything", action: "clearAll"). Lint says destructive-unconfirmed ("takes something away at one press, with no way back. Ask first: a dialog…"). apply_fix({ design, page, rule: "destructive-unconfirmed", nodeId: "<the button id>" }) builds the dialog "Remove everything?" with Cancel and Remove, and moves the action to Remove.
Run. Studio: the problem pill, Fix.
Rally: "Sign out everywhere?", "Delete your account?" on You; "Withdraw from this tournament?" on Tournament.
6. A floating create button
A Fab in the navigation rail's fab slot (the shell floats it on a phone): add_node({ design, page, target: { kind: "slot", parentId: "<NavigationRail id>", slot: "fab" }, type: "Fab", props: { icon: { "$icon": "add" }, label: "Add a thing", href: "/things" } }). A second Fab replaces the first ("It replaced FAB…").
Run: it showed as a green button at the bottom of the phone window. Give it action instead of href to run an action.
Rally: Host ("New tournament") and People (its label is bound: fab.label).
7. Tabs kept in the address
Tabs with param: "tab", each Tab with text, its content in the Tab's slot panel, and exactly one selected: true. The URL becomes …?tab=<tab>; a link or a reload opens the same tab. Without a selected tab lint says tabs-selected: 0 tabs are selected; exactly one should be.
add_node({ design, page, target: { kind: "content" }, type: "Tabs", props: { param: "tab" } })
add_node({ design, page, target: { kind: "slot", parentId: "<Tabs id>", slot: "children" }, type: "Tab", props: { text: "Before", selected: true } })
add_node({ design, page, target: { kind: "slot", parentId: "<Tab id>", slot: "panel" }, type: "Text", props: { text: "Pack the bag." } })Run (generated <TabsView param="tab">). Rally: Games (param: view), People, Tournament.
8. Show or hide by data
Any widget takes showWhen and hideWhen, bound to a value of the page or the row: props: { showWhen: { "$bind": "item.packed", "sample": true } }. An empty string, false or an empty list hides. Studio: select the widget, When does it show?
Run: Tutorial 1 (the "Packed" word and the check button).
Rally: rally--host.ts:148 (playNow.hasGroups), and every card (item.venueLine).
9. A bound icon
An icon that changes with the row: bind the prop and list the icons it can be, so only those are in the page's icon font.
set_props({ design, page, nodeId: "<IconButton id>", props: { icon: { "$bind": "item.icon", "sample": { "$icon": "check_circle" }, "icons": [{ "$icon": "check_circle" }, { "$icon": "circle" }] } } }). The binding gives each row icon: 'check_circle' | 'circle' (things: data.things.map((t) => ({ ...t, icon: t.packed ? 'check_circle' : 'circle' }))), then sync.
Run: two rows drew check_circle, one circle. find_icons({ query: "cart" }) searches the 3,945 symbols.
Rally: the sport icon in the app bar (sport.icon).
10. A leave guard
A button with both href and opens follows the link when nothing was typed, and opens the dialog instead once the page's fields changed.
add_node({ design, page, target: { kind: "content" }, type: "Button", props: { text: "Cancel", variant: "text", href: "/house-rules", opens: "<Dialog id>" } })The dialog's actions: Stay (closes) and Leave (href: "/house-rules").
Run in the app: untouched, Cancel went to /g/house-rules; with text typed, the dialog "Leave without adding?" opened, Leave went on.
Rally: the back button of "Create tournament".
11. Search
A SearchBar with field: "query", and a query param on the list's Query (the starter has both). The binding waits 250 ms after typing, then asks /things?query=…; a page of nothing found shows an EmptyState with repeat: noMatch. Studio: select the bar, set the field.
Run: the starter (type in the box; the list narrows). In the backend the starter's list matches the title and who.
Rally: Find (query, rally--find.ts), People (q), the roster (addQuery).
12. A page only a signed-in person sees
Two halves. Server: set_auth({ design, types: ["session"], roles: ["member", "admin"] }), then set_auth({ design, allowFor: "member" }) (every operation says its lowest role). Pages: add_page({ design, name: "Sign in", route: "/signin", template: "sign-in" }) (email, password, a button calling Session.signIn). Then sync, uv sync (a new dependency, casbin) and restart dev.
Run: signed out, the Things page showed "Not signed in." in its failed banner; member@example.com with dev-member signed in and came back to the page.
Sending a signed-out visitor to the sign-in page is the binding's job: Rally does it in useRead and signedOutRoute() (rally--games.ts:325, :393).
Codes instead of passwords: set_auth takes the type code (Rally's design).
13. Who may do what on an operation
set_service_props({ design, node: "items-complete", props: { allow: "admin" } })
press_operation({ design, operation: "Things.pack", as: "member", params: { id: "<a thing's id>" } }) // 403 "Signed in, but below admin."
press_operation({ design, operation: "Things.list", as: "stranger" }) // 401 "Not signed in."
check_auth({ design }) // every operation as stranger, member, admin, held against its allowRun: check_auth answered "Every answer agrees with the design's allows (12 presses…)". The generated page hides a button the signed-in role may not press. Studio: Backend → Permissions, or the operation's card → "Sign-in is off: anyone may run it" line.
Rally: Backend → Permissions in the studio; roles: player < admin.
14. A new entity and its migration
add_entity({ design, name: "guest", fields: [{ name: "name", type: "string", min: 1, max: 60 }, { name: "coming", type: "boolean" }] })then npx globetrotter sync writes backend/migrations/db/sqlite/0005_add_guest.sql and its Python twin; read it; apply with cd backend && GLOBETROTTER_ENV=local uv run python -m my_first_app_core.migrate. Operations for it (not run): add_operation({ design, service: "Guests", kind: "Query", name: "list", props: { returns: "guest", many: true } }) (a missing service is made and said). propose_operations({ design }) says what the pages need that the service lacks.
Run (entity, sync, migration written). Studio: Backend → Entities → + Entity.
Rally: backend/migrations/db/sqlite/0001…0010.
15. A background job or flow
A flow runs steps after an event. Make the command say what it emits, then the flow and a step:
set_service_props({ design, node: "items-complete", props: { emits: "thing.packed" } })
add_service_node({ design, type: "Flow", target: "flows", props: { name: "tellHost", on: "thing.packed", durability: "inline" } })
add_service_node({ design, type: "Step", target: { parent: "tellHost", slot: "steps" }, props: { name: "writeNote" } })sync writes backend/packages/my_first_app_impl/src/my_first_app_impl/flows.py with a method per step that raises "not written yet"; fill them in, uv sync if it says so. get_runs({ design, flow: "tellHost" }) then shows notify done (try 1, 1 ms) and writeNote done. A Job (type Job) is the scheduled version.
Run: two steps wrote a log line each time a thing was packed. Rally has no flows or jobs (flow_steps returns {}).
16. A notice (snackbar)
Words after an action. Three ways, smallest first: describe_action({ design, name: "create", done: "Thing added." }) (the words when it succeeds, raised by the page itself); return notice from the binding (Tutorial 2: setNotice(\${item.title} is packed.`); undobeside it adds an Undo button); or callnotice(text, { action, undo, tone })from@globetrotter/widgets-m3/runtimein your own code. Run: the binding way (Tutorial 2); thedoneway was accepted by the tool and not looked at in the browser. Rally:import { notice } from '@globetrotter/widgets-m3/runtime'inrally--find.ts, rally--match-score.ts; carryNoticeinrally--games.ts` (a notice that survives a page change).
17. An upload
Supported as a block, not tried end to end. use_service_block({ design, block: "signed-upload" }) adds a File called uploads (10 MB, links that expire) and, after sync, the routes POST /files/uploads and GET /files/uploads/{id} appear in the contract. A file is bytes and an id: keep the id on a row of your own (an attachment entity). sync also changes backend/uv.lock: run uv sync. The block's own words: "A File is bytes and an id, nothing more: it is not tied to a row … by itself."
Not run: the upload itself, and there is no ready-made upload widget in the library; people who need a file input write it in a binding.
Rally has no uploads: its pictures are static SVG files in frontend/public/uploads/.
18. Dark mode and brand colours
set_theme({ design, mode: "dark" }) (light, dark or system) and set_theme({ design, brand: { source: "#2e7d32" } }) (one source colour makes the whole scheme; optional variant, contrast −1 to 1; motion: "expressive" springs). The answer says the colours were written to frontend/src/generated/<design>.brand.css. audit_contrast({ design }) grades every colour pair.
Run: the app on a phone drew in dark with green primaries; the Fab and the Add button took the brand. Studio: select the page, Theme.
Rally: designs/rally.design.json → theme: { mode: "system", motion: "expressive" }.
19. A new page from a template
add_page({ design, name: "Settings", route: "/settings", template: "settings" }). Templates: project (like this project, from its memory), blank, article (a page of words), dashboard, list-detail, detail (a record's page, route /books/[id]), settings, form, sign-in, sign-up, empty. A page joins the rail and the bottom bar by itself, except Blank (pass navigation: true) and Sign in. A record route is written /books/[id], never /books/:id.
Run: blank, article, settings, sign-in, form and list-detail were made. Studio: + beside Pages, New page, name, route, template, Save.
Rally: 32 pages; designs/rally.design.json.
20. A stage site on the internet
Pages on Cloudflare Pages, backend elsewhere (Rally uses Fly.io and Neon). The rehearsal is free and offline:
npx globetrotter deploy --dry-run --name my-game-night --backend-url https://my-api.example.comIt runs sync, builds the pages as plain static files ("Built the site (58 files, 2.0 MB, …)"), and says what it would upload. The real one is the same command without --dry-run, after wrangler is signed in. --backend-url must be a public https:// address; the pages' /api/* is sent there.
Run: the dry run, without and with --backend-url; the refusal for a local address (05, item 14). Not run: a real upload.
Rally: docs/go-live.md; globetrotter.config.json → deploy.