UIGridContainerElement
Represents a container with a grid layout in a panel.
By default, the grid items are vertically stacked, but you can change the grid to use a different layout by setting the grid property to a different value.
grid property is the exact same as CSS's shorthand property grid. See the MDN documentation for more details.
You can understand UIPanel body and footer properties as grid containers using default vertical stack layout.
Horizontal stack
As part of CSS Grid Layout capabilities it is possible to create a horizontal stack.
Alignment & Distribution
On horizontal stacks, it is possible to align and distribute the items.
verticalAlignment is used to align the items vertically. By default, items are aligned to the top of the container. It follows the same values as CSS's align-items property. See MDN documentation for more details.
horizontalDistribution is used to justify the items horizontally. By default, items are justified to the start of the container. It follows the same values as CSS's justify-content property. See MDN documentation for more details.
Equal width columns

{
type: "Grid",
grid: "auto-flow / 1fr 1fr",
items: [
{ type: "TextInput", label: "Name", value: "" },
{ type: "TextInput", label: "Last name", value: "" },
],
}FlexibleSpace element
FlexibleSpace element is a handy solution to allow more control over grid layout.
If grid is not set, FlexibleSpace will add some space between the items. By using grid property it is possible to control FlexibleSpace's size.
to right align the input

{
type: "Grid",
grid: "auto-flow / 1fr 1fr",
items: [
{ type: "FlexibleSpace" },
{ type: "TextInput", label: "An input" , value: "" },
],
}two columns of buttons with space between them

{
type: "Grid",
grid: "auto-flow / auto auto 1fr auto auto",
items: [
{ type: "Button", label: "A" , onClick: () => {} },
{ type: "Button", label: "B" , onClick: () => {} },
{ type: "FlexibleSpace" },
{ type: "Button", label: "C" , onClick: () => {} },
{ type: "Button", label: "D" , onClick: () => {} },
],
}Properties
type
type:
"Grid"
items
items: (
UIButtonElement|UITextElement|UIDividerElement|UITextInputElement|UISelectElement|UIFlexibleSpaceElement|UIButtonRowElement|UICheckboxGroupElement|UIRadioGroupElement|UIToggleGroupElement|UIIframeElement)[]
The items to add to the grid container.
id
id:
string
The ID of the element.
grid?
optionalgrid:string
The grid to use for the container. It is the exact same as CSS's shorthand property grid.
Example
horizontal stack
two columns, the first column is 50px wide, the second column takes the remaining space
{
type: "Grid",
grid: "auto-flow / 50px 1fr",
items: [...]
}See
https://developer.mozilla.org/en-US/docs/Web/CSS/grid for more details.
verticalAlignment?
optionalverticalAlignment:"center"|"top"|"bottom"
The alignment of the items in the grid. Only takes effect on horizontal stacks.
Default Value
"top"
horizontalDistribution?
optionalhorizontalDistribution:"center"|"start"|"end"|"space-between"|"space-around"|"space-evenly"
The distribution of the items in the grid. Only takes effect on horizontal stacks.
Default Value
"start"
onCreate()?
optionalonCreate: (args: {id:string; }) =>void
A function to call when the element is created.
Parameters
args
{ id: string; }
The arguments passed to the function.
args.id
string
The id of the element.
Returns
void
onDestroy()?
optionalonDestroy: (args: {id:string; }) =>void
A function to call when the element is destroyed.
Parameters
args
{ id: string; }
The arguments passed to the function.
args.id
string
The id of the element.
Returns
void
Last updated
Was this helpful?