Stack is a container-type control that allows to define the layout of its children controls.

Although the Stack control has a number of different properties, there are three in particular that define the overall layout that the component has:

  • Direction: Refers to whether the stacking of children components is horizontal or vertical. By default the Stack control is vertical, but can be turned horizontal by adding horizontal property when using the control.
  • Alignment: Refers to how the children controls are aligned inside the container. This is controlled via verticalAlign and horizontalAlign properties.
  • Spacing: Refers to the space that exists between children controls inside the Stack. This is controlled via gap property.

Stacks can be nested inside one another in order to be able to configure the layout of the application as desired.


horizontalboolfalseDefines whether to render Stack children horizontally.
verticalFillboolfalseDefines whether the Stack should take up 100% of the height of its parent.
horizontalAlignstringDefines how to align stack children horizontally: start, end, center, space-between, space-around, space-evenly, baseline or stretch.
verticalAlignstringDefines how to align stack children vertically: start, end, center, space-between, space-around, space-evenly, baseline or stretch.
gapstringA gap between stack child controls.
wrapboolfalseDefines whether Stack children should wrap onto multiple rows or columns when they are about to overflow the size of the Stack.

Child controls#

  • Any control - will be rendered in the body of the stack.


Adding a new horizontal stack to a page:


Adding a stack with buttons in it:

stack1 = page.add(Stack(horizontal=True, controls=[
Button(id="ok", text="OK"),
Button(id="cancel", text="Cancel")

Hiding stack from a previous example:

stack1.visible = False

or shorter:


Removing all children of a stack: