Layout components for widgets
Reference for the stack, row, grid, card, divider and spacer components that arrange other components inside a widget.
Working draft. These docs are illustrative: names, endpoints and examples describe the intended behaviour and can change before launch.
Layout components arrange other components. They hold their content in a children list, so you can nest them. Most widgets use a card as the outer shell and a stack or row inside it.
Components
| Type | What it does |
|---|---|
stack |
Places children one under another. |
row |
Places children side by side. |
grid |
Places children in equal columns. |
card |
Draws a bordered box with an optional title around its children. |
divider |
Draws a thin line between sections. It has no children. |
spacer |
Adds empty space. It has no children. |
Properties
| Property | Applies to | Description |
|---|---|---|
children |
stack, row, grid, card |
The list of components inside. |
gap |
stack, row, grid |
Space between children: small, medium or large. |
align |
stack, row |
start, center or end. |
wrap |
row |
When true, children move to the next line if they do not fit. |
columns |
grid |
Number of columns. The grid uses one column when the chat window is narrow. |
title |
card |
Optional heading shown at the top of the card. |
size |
spacer |
small, medium or large. |
showIf |
All | A binding. The component appears only when the value is true or non-empty. |
Example
{
"type": "card",
"title": "Pick a delivery slot",
"children": [
{
"type": "grid",
"columns": 2,
"gap": "small",
"children": [
{ "type": "button", "label": "Morning", "onClick": "pick", "value": "morning" },
{ "type": "button", "label": "Afternoon", "onClick": "pick", "value": "afternoon" }
]
},
{ "type": "divider" },
{ "type": "caption", "text": "You can change the slot until the day before." }
]
}
You should see a card with two buttons side by side, a line and a small note underneath.
Layout tips
- Start with one
card. A widget with several top-level cards looks like several widgets. - Use
stackfor most of the structure androwonly for small groups, such as a label and a badge. - The chat window can be narrow on phones. Prefer two columns at most in a
grid. - Use
dividerto separate groups. Usespaceronly when a divider would be too strong.
Note: Components inside a layout can still use
showIf. Hiding astackhides everything inside it.
Related pages
- Text and interactive components go inside layouts.
- Code editor shows a full definition with nested components.