For a person or a model about to write an app; a model gets the same text from oad guide.

Contents

Controls#

Controls are the parts a view is built from. They come from the core catalog, which the definition names under uses.catalogs (alias core), and a node names one as core:button. This topic says which control to reach for, then lists every control with its props, events and slots.

Which control#

You want to Use
Lay parts out one after another, or side by side core:stack with direction
Lay out equal columns, such as figures or cards core:grid with columns
Gather related parts under a title core:group
Show one of several panels core:tabs, each child a core:group whose title names its tab
Ask something on top of the view core:dialog, with open bound to view state
Show words core:text, core:heading
Show one key figure core:stat
Show progress toward a target core:progress
Mark a status or a count core:badge with a tone
Say that something failed, needs attention, or worked core:alert with a tone
Show a simple list core:list with an item slot
Show records to compare, sort and pick core:table with columns
Show how numbers compare or change core:chart
Explain how parts connect: an architecture, a flow, a process core:diagram: give boxes and connections, never positions; the host lays them out
Let a person type text, a number or a date core:textInput, core:numberInput, core:dateInput
Let a person pick core:toggle (on or off), core:choice (one option), core:multiChoice (several), core:slider (a number in a range)
Let a person pick a color or a tool core:choice with a swatch or an icon on every option
Let a person attach a file or take a photo core:fileInput (needs no permission)
Gather inputs that are sent together core:form, with submit and cancel
Start something core:button
Go to another view, or to a web address core:link
Draw a game or a custom picture that is not boxes and connections core:canvas

Things to know:

  • Inputs. Every input control has a bindable value and raises change with event.value. Bind value to view state inside a form, or handle change with a run.
  • Labels. Inputs, tables, charts and buttons need a label: it is what the person reads and what assistive technology announces.
  • Numbers. stat, progress, numberInput, slider and table columns take a format (plain, currency, percent). Percent values are fractions: 0.25 shows as 25%.
  • Money. Give "format": "currency" and leave currency out: the host uses the person's currency, env.currency, and shows a plain number when it knows none (the reference host never guesses one). Name a code only when the person named their currency, and never write "=env.currency" in a table column (see mistakes).
  • Choices. options is a list of maps with value and label. The bound value is the picked option's value, with its own type. Make the options from a list with map:

JSON

{ "control": "core:choice", "props": { "label": "Item", "options": "=state.items.map(i, {value: i.id, label: i.name})" } }
  • Colors and tools. A choice of colors or of tools is a core:choice whose options all carry swatch (a color name, as a canvas shape's fill takes) or icon: the host draws up to 12 as small color dots or tool buttons, one picked. A look says "color palette" or "symbol palette" with each option's color or symbol in parentheses, or "not a palette" and why. Never draw a picker on a canvas (see mistakes). A canvas's own tools go in its tools slot, in a vertical stack: such choices and icon-only buttons are drawn in a strip beside the surface, and a slider or another input placed there (a pen size) in a bar under it.

JSON

{ "control": "core:choice", "props": { "label": "Pen", "options": [ { "value": "black", "label": "Black", "swatch": "text" }, { "value": "teal", "label": "Teal", "swatch": "accent" } ] } }
  • Drawing along a drag. A canvas's pointer event has a phase: down at the press, move for each move while pressed, then up, or cancel when the gesture is lost. A pen stroke is one path shape. At down start a stroke in view state with an id (uuid()) and one point, {x: event.x, y: event.y}; at each move append the point to it; at up or cancel add the stroke to the list and clear it. Let the scene draw each stroke, and the one in progress, as one path, so the line shows while it is drawn and a press alone leaves a dot. An eraser takes away the stroke whose id is event.target, the named shape under the pointer. Never build a stroke from one line per move: a canvas draws at most 5000 shapes and 50000 path points and an expression has a budget, and such a stroke meets them within a minute of drawing.
(state.ink + (view.stroke == null ? [] : [view.stroke])).map(s, {kind: 'path', id: s.id, points: s.points, stroke: s.color, strokeWidth: 0.006})
  • Keys for a game. A canvas hears the keys in its keys once the person presses it or tabs to it, and when it gives way to another canvas with keys (by when, as a part's view or in the next view) the keys follow, so a game needs no "click to continue" between its screens.
  • Round and curved shapes. Draw a shape as what it is: a tile with rounded corners is a rect with radius, a stretched circle an ellipse, a gauge or a ring of progress an arc (from and to in degrees clockwise from pointing right, so a ring of progress runs from -90 to -90 + 360 times the share done), and a piece of a pie an arc with a fill. A smooth line or outline is a path whose points carry control points: cx and cy for a gentle bend, c1x, c1y, c2x and c2y for an S or a precise curve. Every line takes dash (dashed, dotted), cap and join; a text takes "weight": "emphasis" to stand out.
  • Colors on a canvas. A color is named by its role, such as text for ink: the host draws it in the page's light or dark mode. A color is a name of the design's (surface, surfaceRaised, surfaceSunken, text, textMuted, border, outline, accent, onAccent, focus, neutral, info, success, warning, danger, category1 to category8); a hex value or a CSS name such as "red" or "none" is not one: the host paints another color in its place, and the look names it. No fill or no stroke is a fill or stroke left out. Give the canvas a mode only when its colors must never change, as in a drawing that is printed.
  • Symbols and motion. A figure a scene shows many times (a block of a game with its light and shade, a playing piece, a marker) is a symbol: write it once in the canvas's symbols, around its origin, in units of the width, with "fill": "given" on the part that takes a color, and place it with a use of its own x, y, scale, rotation and color. A group moves, turns and scales shapes as one: a board of cells is a group scaled to one cell, its blocks placed at their column and row. For motion, give the canvas "motion": "standard" and each shape that moves an id: when the state changes, the host glides it to its new place. A piece a rule moves step by step keeps an even pace with { "over": "PT0.3S", "ease": "linear" } at the rule's interval. A scene paints in order, so draw a label after the piece it stands on: the look names texts later shapes may cut.
{kind: 'group', x: 0.3, y: 0.05, scale: 0.04, shapes: state.cells.map(c, {kind: 'use', symbol: 'block', x: c.col, y: c.row, color: c.color})}
  • Gradients and shadows. A fill may run between colors, {gradient: 'linear', stops: ['category1', 'accent']} (top to bottom; angle 0 runs left to right) or radial from the middle out, and a stop {color: 'surface', opacity: 0} fades to nothing, so a shine is a second shape over a plain one. A shadow of 'low', 'medium' or 'high' lifts a shape, a group or a placement. They serve the few things a person picks up or that catch the light, one level for things of one kind; on every shape, or between unrelated colors, they spoil a drawing. A host that draws neither shows the first stop and no shadow, so put the main color first.
  • Charts. Say what the numbers are: unit for what they count ("hours", "kg"; money and percentages take format instead) and valueLabel for what they are, with categoryLabel for the categories. For a ranking or long category names, lay bars on their side with "orientation": "horizontal". Show a target on a bar, line or area chart with "goal": { "value": 40, "label": "Weekly target" }. A pressed bar, point or slice is kept in selected as { "item": "Mar", "series": "hours" }, the record named by its category or by itemKey: bind it to view state, and set that to null when the app forgets the pick, so the outline goes with the words. In a select handler event.selected is null when the press or Escape cleared the selection, so words about the pick check it first.
  • Tables. With complete true (the default) the host sorts and pages items itself. selected holds the itemKey values of picked rows. A column shows its field as it is. For a stored code in words, give each element the words in a field of their own (see flows), or draw them in the cell slot of a "format": "custom" column, as the reading list does.
  • Items that move between lists. When a person moves items from list to list, such as the cards of a board between its columns, give the lists one moveGroup and each a label, and handle move on each by changing the field the lists filter on to that list's own (made with each, the column's). When a person keeps items in an order of their own, such as priorities or the cards of a column, make the list reorderable and keep the order move gives: { "set": "state.books", "to": "=state.books.sortBy(b, indexOf(event.order, b.id))" }. Shared state is set in an action passed event.order. Such a list shows its items in the order the app keeps them, so sort them by nothing else. The host gives every item its own Move control, so draw no buttons that move an item between those lists or up and down.
  • Images. core:image source and a canvas image shape are remote props. A picture that is part of the app (a header photo, a logo, the sprites of a game) is added first with the tool add_asset, then named as "asset:<name>" (an asset nothing names yet is only a warning): the app carries it, so it shows in the chat too and asks nothing. A picture that differs for each record stays a web address, which needs a grant (see capabilities) and does not show in a chat. At most 64 pictures, each a PNG, JPEG, WebP or GIF of at most 768 KB and 4096 pixels a side, 1.875 MB in all; a picture from the web is not shrunk, so where a library's page offers smaller sizes (Wikimedia Commons, Unsplash, Pexels, Pixabay), take one, and give credit when the license asks. A person's own photo given by path that is too large, or a HEIC, is made smaller on a Mac; elsewhere, ask the person to save it at 2048 pixels on its longer side first. add_asset removes the place where a photo was taken.
  • Formatted text. Text that arrives formatted, such as a model's reply, notes people write or a description from a service, often uses Markdown. Give its core:text "format": "markdown": the host draws its headings, lists, tables, code and links, the same on every host, and shows anything else, HTML included, as its characters. Keep the app's own labels and sentences plain, and never join strings to put marks such as two asterisks or a hash around your own words: style, core:heading, core:badge and core:group do that. A link in it is followed as a core:link with a url is.

JSON

{ "control": "core:text", "props": { "value": "=item.summary", "format": "markdown" } }
  • Variants. variant names a preset of props from the design system. You can always set the props themselves instead, which works with every design system.

Icon names every host knows (for icon props, meta.icon and a main section's icon): add, remove, edit, delete, close, check, search, filter, sort, menu, more, back, forward, up, down, home, settings, user, users, calendar, clock, location, camera, image, file, attach, download, upload, share, copy, link, mail, phone, chat, notification, star, heart, info, help, warning, error, success, lock, play, pause, stop, refresh, chart, dashboard, list, table, folder, tag, inbox, money, undo, redo, eraser, line, rectangle, ellipse, text, pointer, hand, fill. A name the host does not know shows no symbol, and the check warns about it (value.notKnown).

Every control#

Every control also takes variant, hidden and disabled. "Required" props must be set in props or bound in bind. A bindable prop can be bound; a remote prop can make the host fetch from the network, unless it is "asset:<name>".

Types the props use:

  • Spacing: "small" | "medium" | "large"
  • Emphasis: "high" | "medium" | "low"
  • Tone: "neutral" | "info" | "success" | "warning" | "danger"
  • NumberFormat: "plain" | "currency" | "percent"
  • ChoiceValue: string | number | boolean
  • ChoiceOption: value ChoiceValue, label string, description? string, icon? IconName, swatch? string
  • Trend: direction "up" | "down" | "flat", label? string, sentiment? "positive" | "negative" | "neutral"
  • TableColumn: field string, label string, format? "text" | "number" | "currency" | "percent" | "date" | "datetime" | "boolean" | "custom", currency? string, sortable? boolean
  • SortKey: field string, direction "asc" | "desc"
  • ChartSeries: field string, label string, color? string, format? NumberFormat, unit? string
  • ChartGoal: value number, label? string
  • ChartValue: item string | number | boolean, series string
  • Shape: one of these, told apart by kind: "rect" (id? string, x number, y number, width number from 0, height number from 0, radius? number from 0, fill? Fill, stroke? string, strokeWidth? number from 0, dash? "solid" | "dashed" | "dotted", cap? "round" | "flat" | "square", join? "round" | "sharp" | "bevel", rotation? number, opacity? number 0 to 1, motion? Motion, shadow? Shadow); "circle" (id? string, x number, y number, r number from 0, fill? Fill, stroke? string, strokeWidth? number from 0, dash? "solid" | "dashed" | "dotted", cap? "round" | "flat" | "square", opacity? number 0 to 1, motion? Motion, shadow? Shadow); "ellipse" (id? string, x number, y number, radiusX number from 0, radiusY number from 0, fill? Fill, stroke? string, strokeWidth? number from 0, dash? "solid" | "dashed" | "dotted", cap? "round" | "flat" | "square", rotation? number, opacity? number 0 to 1, motion? Motion, shadow? Shadow); "arc" (id? string, x number, y number, radius number from 0, from number, to number, stroke? string, strokeWidth? number from 0, fill? Fill, dash? "solid" | "dashed" | "dotted", cap? "round" | "flat" | "square", join? "round" | "sharp" | "bevel", opacity? number 0 to 1, motion? Motion, shadow? Shadow); "line" (id? string, x number, y number, x2 number, y2 number, stroke? string, strokeWidth? number from 0, dash? "solid" | "dashed" | "dotted", cap? "round" | "flat" | "square", opacity? number 0 to 1, motion? Motion, shadow? Shadow); "path" (id? string, points list, stroke? string, strokeWidth? number from 0, fill? Fill, closed? boolean, dash? "solid" | "dashed" | "dotted", cap? "round" | "flat" | "square", join? "round" | "sharp" | "bevel", opacity? number 0 to 1, motion? Motion, shadow? Shadow); "text" (id? string, x number, y number, text string, size? number from 0, align? "start" | "center" | "end", weight? "body" | "emphasis", fill? Fill, rotation? number, opacity? number 0 to 1, motion? Motion, shadow? Shadow); "image" (id? string, x number, y number, width number from 0, height number from 0, source string, rotation? number, opacity? number 0 to 1, motion? Motion, shadow? Shadow); "group" (id? string, x? number, y? number, scale? number from 0, rotation? number, opacity? number 0 to 1, motion? Motion, shadow? Shadow, shapes Shape[]); "use" (symbol string, id? string, color? string, x? number, y? number, scale? number from 0, rotation? number, opacity? number 0 to 1, motion? Motion, shadow? Shadow)
  • PathPoint: x number, y number, cx? number, cy? number, c1x? number, c1y? number, c2x? number, c2y? number
  • Fill: string (A color token name, such as accent or category2), or { gradient "linear" | "radial", angle? number, stops GradientStop[] }
  • GradientStop: string (A color token name, fully opaque), or { color string, opacity? number 0 to 1, at? number 0 to 1 }
  • Shadow: "low" | "medium" | "high"
  • Motion: string (none, or the name of a motion token of the design system: quick, standard or slow in the default one), or { over string, ease? "smooth" | "linear" }
  • FileKind: "image" | "video" | "audio" | "document" | "spreadsheet" | "text" | "any"
  • FileRef: id string, name string, mediaType string, size? integer from 0, uri? string

core:stack#

Arrange parts one after another, down the view or across it.

  • Props: direction "vertical" | "horizontal" (default "vertical"); gap Spacing (default "medium"); align "start" | "center" | "end" | "stretch" (default "stretch").
  • Children: many.

core:grid#

Arrange parts in equal columns, filling row by row.

  • Props: columns integer 1 to 6 (default 2); gap Spacing (default "medium").
  • Children: many.

core:group#

A titled section that gathers related parts, such as the fields of an address or the figures for one month.

  • Props: title string (required); description string; emphasis Emphasis (default "medium").
  • Slots: actions, one node drawn once, which reads the names around the control.
  • Children: many.

core:tabs#

Show one of several panels at a time, with a tab for each that its panel names, so each child is usually a group whose title names its tab.

  • Props: selected integer (bindable, default 0); label string.
  • Events: change with event holding value integer.
  • Children: many.

core:dialog#

Ask for a person's attention or a short decision on top of the current view, without leaving it.

  • Props: open boolean (bindable, default false); title string (required); dismissible boolean (default true).
  • Events: dismiss with no payload.
  • Children: many.

core:divider#

Separate groups of content with a visible break.

  • Props: label string.

core:text#

Show a piece of text, such as a sentence, a value or a note.

  • Props: value string (required); style "body" | "caption" | "emphasis" (default "body"); format "plain" | "markdown" (default "plain").

core:heading#

Title a view or a section of one, so people can scan and navigate by headings.

  • Props: value string (required); level integer 1 to 3 (default 2).

core:image#

Show a picture, such as a photo, an illustration or a picked image file.

  • Props: source string (remote, required); alt string (required); fit "contain" | "cover" (default "contain"); size "small" | "medium" | "large" | "fill" (default "fill").

core:icon#

Show a small symbol named by meaning, such as add, delete, warning or search.

  • Props: name IconName (required); label string.

core:badge#

Mark something with a short status or count, such as New, Overdue or 3.

  • Props: label string (required); tone Tone (default "neutral").

core:stat#

Show one key figure with its name and, optionally, which way it is moving.

  • Props: label string (required); value number | string (required); format NumberFormat (default "plain"); currency string; trend Trend.

core:progress#

Show progress toward a numeric target, or that work is under way when the amount is unknown.

  • Props: value number?; max number (default 100); label string (required); format NumberFormat (default "plain"); currency string.

core:alert#

Tell a person something important in place: that an action failed, that something needs attention, or that something worked.

  • Props: title string (required); message string; tone Tone (default "info"); dismissible boolean (default false).
  • Events: dismiss with no payload.
  • Slots: actions, one node drawn once, which reads the names around the control.

core:textInput#

Let a person enter text: a name, an email address, a note or a longer description.

  • Props: value string? (bindable); label string (required); hint string; multiline boolean (default false); kind "text" | "email" | "phone" | "url" | "secret" (default "text"); required boolean (default false); maxLength integer from 1; error string?.
  • Events: change with event holding value string?.

core:numberInput#

Let a person enter a number, such as an amount of money, a quantity or a percentage.

  • Props: value number? (bindable); label string (required); hint string; min number; max number; step number from 0; format NumberFormat (default "plain"); currency string; required boolean (default false); error string?.
  • Events: change with event holding value number?.

core:dateInput#

Let a person choose a calendar date, a date and time, or a time of day, such as a due date, an appointment or an alarm.

  • Props: value string? (bindable); mode "date" | "datetime" | "time" (default "date"); label string (required); hint string; min string; max string; required boolean (default false); error string?.
  • Events: change with event holding value string?.

core:toggle#

Let a person turn one setting on or off.

  • Props: value boolean (bindable, default false); label string (required); hint string.
  • Events: change with event holding value boolean.

core:choice#

Let a person pick exactly one option from a list.

  • Props: value ChoiceValue? (bindable); options ChoiceOption[] (required); label string (required); hint string; required boolean (default false); error string?.
  • Events: change with event holding value ChoiceValue?.

core:multiChoice#

Let a person pick any number of options from a list, such as tags or days of the week.

  • Props: value ChoiceValue[] (bindable, default []); options ChoiceOption[] (required); label string (required); hint string; required boolean (default false); error string?.
  • Events: change with event holding value ChoiceValue[].

core:slider#

Let a person set a number within a fixed range by feel, such as volume, a rating or a budget split.

  • Props: value number (bindable, default 0); label string (required); min number (default 0); max number (default 100); step number from 0 (default 1); format NumberFormat (default "plain"); currency string.
  • Events: change with event holding value number.

core:fileInput#

Let a person attach files, or take a photo or recording with the device, for example to add a receipt to an expense.

  • Props: value FileRef[] (bindable, default []); label string (required); accept FileKind[] (default ["any"]); multiple boolean (default false); capture "none" | "camera" | "microphone" (default "none"); required boolean (default false); error string?.
  • Events: change with event holding value FileRef[].

core:form#

Gather related inputs into one unit that is submitted together, and report whether every input is acceptable.

  • Props: label string; submitLabel string; cancelLabel string.
  • Events: submit with no payload; cancel with no payload.
  • Outputs (bind them to read them): valid boolean.
  • Children: many.

core:button#

Let a person start something: save, send, add, delete, start a game.

  • Props: label string (required); emphasis Emphasis (default "medium"); icon IconName; destructive boolean (default false); iconOnly boolean (default false).
  • Events: press with no payload.

Take a person somewhere: another view of this app, or a web address outside it.

  • Props: label string (required); view string; input any; url string.
  • Events: activate with no payload.

core:list#

Show a collection of items one after another, each drawn by the item template, and let a person pick one, move one to another list, or put one at a place of their choosing.

  • Props: items any[] (required); itemKey string (default "id"); label string; empty string; moveGroup string; reorderable boolean (default false).
  • Events: select with event holding item any, index integer; move with event holding item any, index integer?, order any[]?.
  • Slots: item (required), whose node reads item, index; actions, one node drawn once, which reads the names around the control.

core:table#

Show records as rows with named columns so people can compare, sort, select and page through them.

  • Props: items any[] (required); columns TableColumn[] (required); label string (required); itemKey string (default "id"); complete boolean (default true); sort SortKey? (bindable); pageSize integer from 1; page integer from 1 (bindable, default 1); total integer from 0; selection "single" | "multiple" (default "single"); selected any[] (bindable, default []); empty string.
  • Events: select with event holding item any, index integer, selected any[]; sort with event holding field string, direction "asc" | "desc"; page with event holding page integer.
  • Slots: cell, whose node reads item, index, column, value; actions, one node drawn once, which reads the names around the control.

core:chart#

Show how numbers compare or change, drawn from a list of records.

  • Props: kind "bar" | "line" | "area" | "pie" | "scatter" (required); items any[] (required); category string (required); series ChartSeries[] (required); label string (required); stacked boolean (default false); format NumberFormat (default "plain"); currency string; unit string; categoryLabel string; valueLabel string; orientation "vertical" | "horizontal" (default "vertical"); goal ChartGoal; selected ChartValue? (bindable, default null); itemKey string.
  • Events: select with event holding item any, series string, selected ChartValue?.
  • Slots: actions, one node drawn once, which reads the names around the control.

core:canvas#

A drawing surface for casual games and custom visuals.

  • Props: scene Shape[] (remote, required); label string (required); summary string; aspect number 0.1 to 10 (default 1); background string; mode "light" | "dark"; keys string[] (default []); symbols object (remote); motion Motion (default "none").
  • Events: pointer with event holding phase "down" | "move" | "up" | "cancel", x number, y number, target string?; key with event holding key string, phase "down" | "up", repeat boolean.
  • Slots: actions, one node drawn once, which reads the names around the control; tools, one node drawn once, which reads the names around the control.

core:diagram#

Explain how parts connect: an architecture, a flow or a process.

  • Props: boxes DiagramBox[] (required); connections DiagramConnection[] (default []); groups DiagramGroup[]; selected string? (bindable, default null); highlight string[] (default []); label string (required); summary string.
  • Events: select with event holding box DiagramBox?, selected string?.
  • Slots: actions, one node drawn once, which reads the names around the control.

Next#

  • views for nodes, bindings and handlers.
  • capabilities for what the app uses outside the screen.