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.
How to define them
Section titled “How to define them”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": [] } ] } ]}| Property | Description |
|---|---|
uid | Optional unique id; one is generated if absent. |
kind | MANDATORY. Always 'layout'. |
type | MANDATORY. The layout type (grid, tabs, accordion). |
children | MANDATORY for grid. An array of child widgets. (Tabs and accordion match each child by uid to a section declared in props.) |
props | Layout-specific configuration: direction, columns, gap, justify, tab and section definitions. See each layout’s reference page. |
Grid for every arrangement
Section titled “Grid for every arrangement”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.
Available widgets
Section titled “Available widgets”| Widget | DX shortcut | Reference |
|---|---|---|
| Grid | gui.layouts.grid | Grid |
| Tabs | gui.layouts.tabs | Tabs |
| Accordion | gui.layouts.accordion | Accordion |
| Custom | gui.layouts.custom | Custom Widgets |
| Flex | gui.layouts.flex | Flex, deprecated |
See also
Section titled “See also”gui.layoutsreference — every layout shortcut.- Extending GolemUI / Layout Widget — build your own.