Skip to content

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 = [
// Grid for rows — subgrid keeps labels and inputs aligned across all children.
gui.layouts.grid([
gui.inputs.textInput('user.firstName'),
gui.inputs.textInput('user.lastName'),
]),
// Flex for columns.
gui.layouts.flex(
[
gui.inputs.textInput('user.email'),
gui.inputs.password('user.password'),
],
{ direction: 'column' },
),
// Tabs — first arg is sections, each with its own children.
gui.layouts.tabs([
{ label: 'Personal', uid: 'personal', children: [/* ... */] },
{ label: 'Work', uid: 'work', children: [/* ... */] },
]),
];
ShortcutDescription
gui.layouts.flexFlex container (Flex).
gui.layouts.horizontalFlexFlex with direction: 'row'.
gui.layouts.verticalFlexFlex with direction: 'column'.
gui.layouts.gridGrid container with subgrid alignment (Grid).
gui.layouts.horizontalGridGrid with direction: 'row'.
gui.layouts.verticalGridGrid with direction: 'column'.
gui.layouts.tabsTabs (Tabs).
gui.layouts.accordionAccordion (Accordion).
gui.layouts.customPlug in your own layout (Custom Widgets).
  • Use grid for rows. CSS subgrid keeps labels, inputs, and validation messages aligned across every child in the row.
  • Use flex for columns. Lighter, more flexible for vertical stacks.

The same widget in JSON, with props and children separated:

{
"form": [
{
"kind": "layout",
"type": "grid",
"props": { "direction": "row", "autoFit": true },
"children": [
{ "kind": "input", "type": "textinput", "path": "user.firstName" },
{ "kind": "input", "type": "textinput", "path": "user.lastName" }
]
}
]
}
PropertyDescription
uidOptional unique id; one is generated if absent.
kindMANDATORY. Always 'layout'.
typeMANDATORY. The layout type (flex, grid, tabs, accordion).
childrenMANDATORY for flex / grid. An array of child widgets. (Tabs and accordion put children inside their sections.)
propsLayout-specific configuration — direction, gap, align/justify, etc. See each layout’s reference page.