> For the complete documentation index, see [llms.txt](https://docs.flatredball.com/gum/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.flatredball.com/gum/gum-tool/tutorials-and-examples/examples/bottom-up-stack.md).

# Bottom-Up Stack

Bottom-up stacks can be used to display stacks of elements which should move up as more are added. This concept is similar to messages received in a chat window. Gum layout can be used to produce this type of stack.

{% hint style="info" %}
This example shows a bottom-up stack (vertical) but the same approach could be used to create a right-aligned stack.
{% endhint %}

Items in a bottom-up stack need a parent Container. This Container could be an instance of a Container or a component since components usually have their `Base Type` set to Container. For this example we'll use a container.

<figure><img src="/files/DeuteX0qywby7s6aiOqR" alt=""><figcaption><p>Container instance</p></figcaption></figure>

This container to stack needs the following variables set:

* `Children Layout` set to `Top to Bottom Stack` so all children stack vertically

  <figure><img src="/files/BpP6ZDHkaqDYHyCswzrk" alt=""><figcaption><p><code>Children Layout</code> set to <code>Top to Bottom Stack</code></p></figcaption></figure>
* `Height Units` set to `Relative to Children` so the container resizes itself as more children are added

  <figure><img src="/files/JmZxjvUYQUPMLP0Nzhac" alt=""><figcaption><p><code>Height Units</code> set to <code>Relative to Children</code></p></figcaption></figure>
* `Height` set to `0` so the effective height of the container is based purely on its children

  <figure><img src="/files/zWrvVdmtWcYTyLPFxRws" alt=""><figcaption><p><code>Height</code> set to <code>0</code></p></figcaption></figure>
* `Stack Spacing` set to `2` (optional) to add spacing between each child

  <figure><img src="/files/V4lstghzZgj00KQkElwx" alt=""><figcaption><p><code>Stack Spacing</code> set to <code>2</code></p></figcaption></figure>

Now children of the Container stack vertically. This concept works for any type of child, but we'll use ColoredRectangles for this example. Add a few instances to the Container and they stack vertically.

<figure><img src="/files/S34FYcQLoQtT0pSKpRr1" alt=""><figcaption><p>ColoredRectangle instances stacking vertically in a container</p></figcaption></figure>

Finally we can have the stack grow up instead of down. To do this, change the following variables on the parent container:

* `Y Origin` set to `Bottom`

  <figure><img src="/files/pwn1ZElg0BpglUioty6Z" alt=""><figcaption><p><code>Y Origin</code> set to <code>Bottom</code></p></figcaption></figure>
* `Y Units` set to `Pixels from Bottom`

  <figure><img src="/files/B0xUC2LBiv4m3l9ochqM" alt=""><figcaption><p><code>Y Units</code> set to <code>Pixels from Bottom</code></p></figcaption></figure>

Now as new children are added, the parent stack grows and all items shift up.

<figure><img src="/files/9JPAuFfbjI5l8mEs2fbo" alt=""><figcaption><p>Stack grows upward as more children are added</p></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.flatredball.com/gum/gum-tool/tutorials-and-examples/examples/bottom-up-stack.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
