Skip to content
Forms, switch product

Layout Widgets Overview

Layout widgets are containers. They take a children array (a tabs/accordion takes a sections array of { label, uid, children }) and arrange them visually. They have no path and don’t write to form data themselves.

import { gui } from '@golemui/gui-shared';
const formDef = [
// A row: the fields line up their labels, controls and errors.
gui.layouts.horizontalGrid([
gui.inputs.textInput('user.firstName'),
gui.inputs.textInput('user.lastName'),
]),
// A stack, one field below the other.
gui.layouts.grid([gui.inputs.textInput('user.email'), gui.inputs.password('user.password')]),
// Tabs — first arg is sections, each with its own children.
gui.layouts.tabs([
{
label: 'Personal',
uid: 'personal',
children: [
/* ... */
],
},
{
label: 'Work',
uid: 'work',
children: [
/* ... */
],
},
]),
];

gui.layouts.horizontalGrid is a grid with { direction: 'row' }, and verticalGrid one with { direction: 'column' }, the default. See the gui.layouts reference for the full list.

Same outcome in JSON: grid carries children directly; tabs and accordion declare their sections in props.tabs/props.sections and bind each section’s content to a child by matching uid:

{
"form": [
{
"kind": "layout",
"type": "grid",
"props": { "direction": "row" },
"children": [
{ "kind": "input", "type": "textinput", "path": "user.firstName" },
{ "kind": "input", "type": "textinput", "path": "user.lastName" }
]
},
{
"kind": "layout",
"type": "grid",
"children": [
{ "kind": "input", "type": "textinput", "path": "user.email" },
{ "kind": "input", "type": "password", "path": "user.password" }
]
},
{
"kind": "layout",
"type": "tabs",
"props": {
"tabs": [
{ "uid": "personal", "label": "Personal" },
{ "uid": "work", "label": "Work" }
]
},
"children": [
{ "uid": "personal", "kind": "layout", "type": "grid", "children": [] },
{ "uid": "work", "kind": "layout", "type": "grid", "children": [] }
]
}
]
}
PropertyDescription
uidOptional unique id; one is generated if absent.
kindMANDATORY. Always 'layout'.
typeMANDATORY. The layout type (grid, tabs, accordion).
childrenMANDATORY for grid. An array of child widgets. (Tabs and accordion match each child by uid to a section declared in props.)
propsLayout-specific configuration: direction, columns, gap, justify, tab and section definitions. See each layout’s reference page.

Use grid for stacks, rows and columns alike. In a row or in columns, it keeps the labels, controls and errors of the fields next to each other aligned. The flex layout is deprecated: it still renders, as a grid, and v3.0.0 removes it. See Flex for how its props map.

WidgetDX shortcutReference
Gridgui.layouts.gridGrid
Tabsgui.layouts.tabsTabs
Accordiongui.layouts.accordionAccordion
Customgui.layouts.customCustom Widgets
Flexgui.layouts.flexFlex, deprecated