Skip to content

Flex ​

extends Container

Shared flex-style layout container used by Row and Column.

Types ​

FlexDirection ​

lua
FlexDirection = "row"|"column"

FlexJustify ​

lua
FlexJustify = "start"|"center"|"end"|"spaceBetween"

FlexOverflow ​

lua
FlexOverflow = "clip"

Properties ​

PropertyTypeDefaultDescription
directionFlexDirection"row""row" or "column"
gapnumber0cells between children on the main axis
paddingnumber0inner spacing on all sides
alignElementAlignment"start"cross axis: start, center, end, stretch
justifyFlexJustify"start"main axis: start, center, end, between
overflowFlexOverflow"clip"how overflowing children behave
backgroundnumber|falsefalseBackground color (false = transparent)

Methods ​

Flex:measure(availableWidth, availableHeight) ​

Intrinsic size: sum of the children along the main axis plus gaps and padding (used by basalt.auto()).

  • availableWidth (number, optional) Space offered by the parent

  • availableHeight (number, optional) Space offered by the parent

  • returns width (number) The measured width

  • returns height (number) The measured height

Flex:layoutChildren() ​

Positions all children according to direction/gap/align/justify; called automatically before every render pass.

Last updated:

Released under the MIT License.