v22.18.0 release notes

FormBuilder

FormBuilder is a visual editor of FormRenderer schemas: a palette of field types, a canvas with a live preview, drag and drop with a full keyboard alternative, a properties panel for validation, options and conditions, sections, steps, undo and redo, and JSON import and export.

View as .md
import { UIFormBuilder } from '@exhaustive-ui/core/formbuilder';

FormBuilder edits the schema of a FormRenderer, bound with [(schema)]. Add a field from the palette with a click, or drag it to a place on the canvas; the canvas shows each field as FormRenderer draws it. Select a field to edit its label, key, hint, validation, options and conditions in the properties panel, and drag it or use the move buttons to reorder it. The toolbar has undo and redo, a live preview of the whole form and a JSON view to copy, download or import the schema. On narrow screens, the palette, the canvas and the properties become tabs.

Fields

Pick a field to add it after the selection, or drag it onto the form.

Form
Press Alt and the up or down arrow to move the field, Delete to remove it.
Form settings
Schema
{
  "version": 1,
  "title": "Event registration",
  "columns": 2,
  "fields": [
    {
      "key": "name",
      "type": "text",
      "label": "Name",
      "required": true
    },
    {
      "key": "email",
      "type": "email",
      "label": "Email",
      "required": true
    },
    {
      "key": "ticket",
      "type": "radio",
      "label": "Ticket",
      "options": [
        "Standard",
        "VIP"
      ],
      "default": "Standard",
      "colSpan": 2
    },
    {
      "key": "dinner",
      "type": "checkbox",
      "label": "I join the dinner"
    }
  ]
}

types limits the palette to the allowed field types, in their order. palette replaces it with your own items: a type, a label and defaults merged into the new field, so a preset such as a country list or a consent checkbox is one click away. validatorNames lists the custom validators the properties panel offers, and validators and loaders give their functions to the previews. showPreview and showJson hide the views of the toolbar, breakpoint sets the width under which the panels become tabs, and every text is replaced or translated with labels or the formBuilder key of the locale texts.

Fields

Pick a field to add it after the selection, or drag it onto the form.

Form
Press Alt and the up or down arrow to move the field, Delete to remove it.
Form settings

The schema is plain JSON: save it to a server, then render it anywhere with FormRenderer. Steps and sections are managed from the canvas header with Add section and Add step; select a section or a step to edit its title, description, columns and visibility. Here the form below follows the builder as you edit it.

Fields

Pick a field to add it after the selection, or drag it onto the form.

Form
Press Alt and the up or down arrow to move the field, Delete to remove it.
  • Drop files here or browse
Form settings
Job application

Screen Reader

FormBuilder is a region named by ariaLabel. The palette, the canvas and the properties are titled sections, and every action of drag and drop has a button: the palette items add a field after the selection, and each field has buttons to move it up or down, duplicate it and remove it, named after the field, such as Move Email, Email down. A field of the canvas is a toggle button with aria-pressed when it is selected, and its preview is inert, so it is neither focused nor read twice.

Adding, moving, removing a field, undo and redo are announced by a polite live region, such as Email, Email moved to position 2, and the focus follows the field or goes to the next one after a removal. The key of a field is checked as you type, with an error linked to its input when another field uses it.

Keyboard Support

KeyFunction
enter / spaceOn a palette item, adds the field; on a field of the canvas, selects it.
alt + up arrow / alt + down arrowOn a field of the canvas, moves it up or down.
deleteOn a field of the canvas, removes it.
ctrl + zUndoes the last change, outside of a text input.
ctrl + shift + z / ctrl + yRedoes the last undone change, outside of a text input.