1.2 KiB
1.2 KiB
A Flexbox is a layout container that is designed to make it easier to create flexible and responsive UI designs. It allows you to arrange and align its children (elements) within it in a more efficient way.
In addition to the methods inherited from Frame, Container, VisualObject and Object, Flexbox has the following methods:
| setSpacing | Sets the space between objects |
| getSpacing | Returns the space between objects |
| setFlexDirection | Sets the direction in which the children will be placed |
| setJustifyContent | Determines how the children are aligned along the main axis |
| setAlignItems | Determines how the children are aligned along the off axis |
Example
Here's an example of how to create a Flexbox object:
local main = basalt.createFrame()
local flexbox = main:addFlexbox()
:setFlexDirection("column")
:setJustifyContent("space-between")
:setAlignItems("center")
:setSpacing(5)
Alternatively, you can create a flexbox using an XML layout:
<flexbox flexDirection="column" justifyContent="space-between" alignItems="center" spacing="5">