Skip to main content

Positioning

In PixiJS Layout, positioning determines how a node is placed within its container.
You can control how an object participates in the flex flow, or opt to position it independently using absolute or inset positioning.

Position Types

There are three available position types:

PositionDescription
relative (default)The node participates in the normal flex flow.
Insets (top, left, right, bottom) move it relative to its computed flexbox position.
absoluteThe node is removed from the flex flow. It does not affect siblings. Insets position it relative to its containing block.
staticThe node behaves like relative, but ignores all insets.
sprite.layout = {
position: 'absolute',
};

Using Insets (Top, Left, Bottom, Right)

Insets allow you to adjust a node’s location based on its position type

valueDescription
leftThe inset from the left edge of the container.
topThe inset from the top edge of the container.
rightThe inset from the right edge of the container.
bottomThe inset from the bottom edge of the container.
startThe inset from the start edge of the container (left for LTR, right for RTL).
endThe inset from the end edge of the container (right for LTR, left for RTL).
sprite.layout = {
position: 'relative',
left: 20,
top: 10,
};
sprite.layout = {
position: 'absolute',
left: 0,
top: 0,
};

Handling Opposite Insets

If you set both opposing insets (e.g., left and right or top and bottom):

  • The start inset has priority (left over right, top over bottom) when positioning.
  • If the node has a fixed width or height, the opposing insets define alignment relative to the container.
  • If width/height are flexible, layout may stretch or shrink the node.