border Layout
The border layout is one of the fundamental and most useful layouts for compositing UIs.
{
"type": "view",
"layout": "border",
"padding": 8,
"spacing": 4,
"components": [
{
"constraints": {
"region": "top"
},
"type": "label",
"text": "Hello World!"
}
]
}
Set the region constraint on each component to define 1 of 5 positions within the view. Empty space is perfectly valid, and there is no requirement to add a component to each region.
Components in the top, left, bottom and right will take up as much space as they need in the layout, and centre will assume the remaining space.
The top and bottom components take the full width of the layout; the left and right components take the remaining height.
TipWe recommend using the
borderlayout to composite your UIs into smaller parts, adding further views / layouts to the regions of the border layout.It is also normal to use the
borderlayout with only a couple of regions, for example a sidebar to theleftand the content in thecentre.
Properties
Properties on the view which affect the layout:
- padding
- INTEGER
- Default:
0, Range:0-64
Inset the content around the perimeter of the view by the padding amount.
Constraints
Constraints set on each component added to the view:
- region
- ENUM
- Required for
borderlayout
Used by the border layout to position the view.
| Value | Description |
|---|---|
"top" |
Position in the top region, with full width |
"right" |
Position in the right region, with remaining height |
"bottom" |
Position in the bottom region, with full width |
"left" |
Position in the left region, with remaining height |
"centre" |
Position in the centre with remaining width and height |
Each component can use the shared constraints to refine their position within the layout.
Resizing Behaviour
The top and bottom components use their desired height, and will fill the entire width of the view.
The left and right components use their desired width, and will fill the remaining height of the window after the top and bottom space.
The centre component uses the remaining space in the centre.