Skip to main content

Build a form

Settings pages, properties panels and data entry all share one layout: a column of fields, each with a label, and the controls lined up so the eye can run down them.

A settings form with its labels on the left

Two settings do most of the work:

  • Label position on each widget puts its label above or to the left of the control
  • Label width on the container that holds the form sets one label column for every widget inside

Put the labels beside the controls​

  1. Add the widgets of your form to a container, see Build the user interface
  2. On each widget, set Label position to Left
  3. Select the container and set Label width (widgets with Left labels) so the longest label fits

Every widget inside the container now starts its control at the same edge, including widgets in nested containers and in the rows of a UI template list.

Label positionWhat it looks like
DefaultThe widget's own look: a floating label inside a text field, a title above a group, text beside a switch
AboveA plain label above the control
LeftA plain label in a column to the left, with the control beside it

The label position only changes the user interface. On the canvas, widgets keep their usual look.

tip

Use the same position for every widget of a form. A form that mixes Default and Left won't line up.

Widgets that have a label position​

Text Field, Number Field, Dropdown (single select), Dropdown (multi select), Autocomplete (single select), Autocomplete (multi select), Switch, Checkbox, Radio Button, Slider, Color picker, Button Group, Button, Share Button and Diode.

A few of them behave slightly differently in a form:

  • Switch: for an on/off value that should look like the rest of a form, set Control to Checkbox. It is still one on/off value. The Checkbox node is for picking several options from a list.
  • Button: its Label is the text on the button, so a button has no label of its own. With Left, the label column stays empty and the button starts where the other controls start.
  • Diode: its Label moves into the label column, which makes it a status row, such as "Connected" with a light beside it.
  • Slider: a {{value}} in its Label stays live, so the label can show the current value.

On narrow screens​

A label moves above its control when there isn't room for both side by side. That happens once the widget is narrower than the label width plus 216px: a 16px gap and at least 200px for the control. With the default label width of 160px, that point is 376px.

On a phone the labels sit above their controls

This is measured per widget, not per screen. A form in a narrow column next to other content puts its labels above too, even on a wide screen. A shorter label width keeps the labels on the left in a narrower column.

Build a form from JSON​

To edit a settings file, or any nested JSON, you don't need to place a widget per value. A UI template list builds one row per value:

  1. Build a template for one field, see Create reusable UI templates:
    • Add a Text Field, a Number Field and a Switch with Control set to Checkbox, all with Label position set to Left
    • Connect the parameter that receives the key to each widget's Label, and the value to each widget's initial value
    • Feed the value into a Type of node, and connect Is String, Is Number and Is Boolean to the matching widget's visible input on the surface, so each row shows only the widget that suits its value
    • Add a Select by key node: connect Type of's Type to its Key, each widget's Out to the case of the same kind (String, Number, Boolean) and the value to Default. Connect its Output to the template's Output 1.
    • Optionally, add a text widget for headings: show the key in it and connect the group parameter to its visible input
  2. Add a UI template list, pick the template, connect your JSON to Items and turn on Expand nested
  3. Put the list in a container and set the container's label width

Each nested object or list gets a row of its own, which the template can show as a heading. The list's Output is the edited JSON, in the same shape as what came in.

Rows are indented by Indent per level, and the whole row moves, so the controls of nested rows start further right. That shows the structure of the data. If you would rather have every control on one edge, set Indent to 0 and let the headings show the structure.

Style the labels​

The labels of Above and Left widgets use the theme's secondary text color, so the values stand out, the same as the labels widgets draw with Default. They can be restyled together, for example in capitals or in the full text color. See Style form labels.