Skip to main content

Yoga Layout Properties

Full reference for all Yoga flexbox properties available in XFrames. For a tutorial-style introduction, see the Layout guide.

Flex container

Properties that control how a container arranges its children.

PropertyValuesDescription
flexDirection"column", "row", "column-reverse", "row-reverse"Main axis direction. Default: "column"
justifyContent"flex-start", "center", "flex-end", "space-between", "space-around", "space-evenly"Alignment along the main axis
alignItems"auto", "flex-start", "center", "flex-end", "stretch", "baseline"Alignment along the cross axis
alignContent"auto", "flex-start", "center", "flex-end", "stretch", "space-between", "space-around", "space-evenly"Alignment of wrapped lines
flexWrap"no-wrap", "wrap", "wrap-reverse"Whether children wrap to new lines
{
flexDirection: "row",
justifyContent: "space-between",
alignItems: "center",
}

Flex item

Properties that control how a child behaves within its container.

PropertyTypeDescription
flexnumberShorthand for grow. flex: 1 fills available space
flexGrownumberHow much the item grows relative to siblings
flexShrinknumberHow much the item shrinks. Use 0 to prevent shrinking
flexBasisnumberInitial size before grow/shrink (pixels)
flexBasisPercentnumberInitial size as a percentage
alignSelf"auto", "flex-start", "center", "flex-end", "stretch", "baseline"Override parent's alignItems for this child
// Two columns: sidebar (1/3) and main (2/3)
sidebar: { flex: 1 },
main: { flex: 2 },

Sizing

PropertyTypeDescription
widthnumber | stringWidth in pixels or percentage ("50%")
heightnumber | stringHeight in pixels or percentage ("100%")
minWidthnumber | stringMinimum width
maxWidthnumber | stringMaximum width
minHeightnumber | stringMinimum height
maxHeightnumber | stringMaximum height
aspectRationumberWidth-to-height ratio (e.g. 1.0 for square)
{ width: "100%", height: 200 }       // full width, 200px tall
{ width: "50%", aspectRatio: 1.0 } // half width, square

Spacing

padding, margin, and gap use object syntax with edge/gutter keys — not plain numbers.

warning

padding: 8 will not work. Always use an object: padding: { all: 8 }.

Edge keys (for padding, margin, position)

KeyApplies to
allAll four sides
horizontalLeft and right
verticalTop and bottom
leftLeft side only
topTop side only
rightRight side only
bottomBottom side only
startLogical start (respects direction)
endLogical end (respects direction)
padding: { all: 8 }                        // 8px on every side
padding: { horizontal: 12, vertical: 4 } // 12px left/right, 4px top/bottom
margin: { bottom: 4 } // 4px bottom margin only
padding: { left: 8, right: 8, bottom: 4 } // individual edges

Gutter keys (for gap)

KeyApplies to
allBoth directions
columnHorizontal gap between items
rowVertical gap between items
gap: { column: 8 }     // 8px between items in a row
gap: { row: 4 } // 4px between items in a column
gap: { all: 8 } // 8px in both directions

Positioning

PropertyValuesDescription
positionType"static", "relative", "absolute"Positioning mode
positionEdge objectOffset from edges (used with relative or absolute)
// Absolute positioning: 10px from top-right corner of parent
{
positionType: "absolute",
position: { top: 10, right: 10 },
width: 100,
height: 40,
}

Overflow

ValueDescription
"visible"Content may overflow the container (default)
"hidden"Clip overflowing content
"scroll"Show scrollbars when content overflows

See the Layout guide — Scroll containers for details on setting up scrollable areas.

Display

ValueDescription
"flex"Normal layout (default)
"none"Hide the element and its children
// Conditionally hide an element
style={{ display: showPanel ? "flex" : "none", width: "100%", flex: 1 }}

Direction

ValueDescription
"inherit"Inherit from parent (default)
"ltr"Left-to-right
"rtl"Right-to-left

Controls the meaning of start/end edge keys in padding, margin, and position.