# 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="https://2695663588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fzQmxQ1VeUFHcoo2c%2Fuploads%2Fgit-blob-0cc40a070be390ae547ba1b17520c7f2e30335e0%2Fimage%20(3)%20(1)%20(1)%20(1)%20(1)%20(1).png?alt=media" 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="https://2695663588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fzQmxQ1VeUFHcoo2c%2Fuploads%2Fgit-blob-8948341030c6bc1eb348d47c042f3d9bb47ff8cc%2FChildrenLayoutTopToBottom.png?alt=media" 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="https://2695663588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fzQmxQ1VeUFHcoo2c%2Fuploads%2Fgit-blob-4bee3b3227bd465bbe04636478f699b9b0576d16%2Fimage%20(2)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1).png?alt=media" 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="https://2695663588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fzQmxQ1VeUFHcoo2c%2Fuploads%2Fgit-blob-7ca8d0b0ba396a50bdff1fe7a4958b20a9e94b02%2Fimage%20(3)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1).png?alt=media" 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="https://2695663588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fzQmxQ1VeUFHcoo2c%2Fuploads%2Fgit-blob-4b85baf4c3b954d7e1ad8faa26d483bccf24698b%2Fimage%20(4)%20(1)%20(1)%20(1)%20(1).png?alt=media" 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="https://2695663588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fzQmxQ1VeUFHcoo2c%2Fuploads%2Fgit-blob-aec4b1950d498874a3347afb5c3b31064303b0d4%2Fimage%20(5)%20(1)%20(1).png?alt=media" 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="https://2695663588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fzQmxQ1VeUFHcoo2c%2Fuploads%2Fgit-blob-7a8663c9a3752913ef76236411a1718a8d360519%2Fimage%20(6)%20(1)%20(1).png?alt=media" 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="https://2695663588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fzQmxQ1VeUFHcoo2c%2Fuploads%2Fgit-blob-4a7f1da7ea8f72865cbe87abaa71918d59b1a189%2Fimage%20(7)%20(1)%20(1).png?alt=media" 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="https://2695663588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fzQmxQ1VeUFHcoo2c%2Fuploads%2Fgit-blob-c6a27a62992673634a9c359d879bd3e612244149%2F08_21_40_58.gif?alt=media" alt=""><figcaption><p>Stack grows upward as more children are added</p></figcaption></figure>
