> For the complete documentation index, see [llms.txt](https://cardstock-studio.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cardstock-studio.gitbook.io/docs/design/templates-design-your-cards/layers/grids.md).

# Grids

<figure><img src="https://2449056524-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FK6BdQXak9wiY4BdSf9Rq%2Fuploads%2FMsLXQVMgbIjceZxdCgGk%2FScreenshot%202026-05-20%20at%208.40.08%E2%80%AFPM.png?alt=media&amp;token=d773c5ef-7cf5-46bd-8ff3-6b55fdf7a503" alt=""><figcaption></figcaption></figure>

<mark style="color:$success;">**Grids**</mark> will automatically position their children along a Grid, with options to determine the spacing, size, order, and direction of the Grid.

The Grid area can be styles with Components, and the individual <mark style="color:$success;">**Cells**</mark> can also have styling which will display on each Cell.

Children will be positioned automatically, but can scale as they'd like, and children of children can be repositioned relative to their own parent.

***

## Cell Template Styling

<figure><picture><source srcset="/files/VPMrJvgCmxd43bnlSWF3" media="(prefers-color-scheme: dark)"><img src="https://2449056524-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FK6BdQXak9wiY4BdSf9Rq%2Fuploads%2FDpq3mJ1zHu6UtradzbGj%2FScreenshot%202026-05-20%20at%208.40.39%E2%80%AFPM.png?alt=media&amp;token=1f3850da-444b-40dc-99ea-6d2dc8bb4ce9" alt="" width="305"></picture><figcaption></figcaption></figure>

Each Grid comes with a <mark style="color:$success;">**Cell Template**</mark> child Layer is NOT included in the grid, but any Components added to this Layer will affect the style of each Cell in the Grid, including any child layers.

In this example, the "Circle" Layer is a child of the Cell Template, and positioned outside of the Cell area.

<figure><img src="https://2449056524-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FK6BdQXak9wiY4BdSf9Rq%2Fuploads%2FuogYKCCCOPIpdJtDUbbS%2FScreenshot%202026-05-20%20at%208.42.15%E2%80%AFPM.png?alt=media&amp;token=796d2a66-a32f-4705-95ec-0d69e703bba1" alt="" width="313"><figcaption></figcaption></figure>

<figure><img src="https://2449056524-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FK6BdQXak9wiY4BdSf9Rq%2Fuploads%2FIE63x2Cabnb7Mh11nkiU%2FScreenshot%202026-05-20%20at%208.42.09%E2%80%AFPM.png?alt=media&amp;token=8f562320-77b6-4708-9ae4-8d95a8dcc49b" alt=""><figcaption></figcaption></figure>

***

## Mask Cell Area & Mask Children

Toggle <picture><source srcset="/files/6jz0ZUCdCL3psUNE1lFe" media="(prefers-color-scheme: dark)"><img src="https://2449056524-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FK6BdQXak9wiY4BdSf9Rq%2Fuploads%2FLhwKT8mlsCbVDQaeVPgB%2FScreenshot%202026-05-20%20at%208.52.03%E2%80%AFPM.png?alt=media&amp;token=58ba32b2-1a0d-4acb-9699-0f3d3904cc16" alt="" data-size="line"></picture> in the Grid properties to clip children of the Cell Template that is outside of the Cell area.

<figure><img src="https://2449056524-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FK6BdQXak9wiY4BdSf9Rq%2Fuploads%2FrH7SFleyjIhmJSQ4AFCd%2FScreenshot%202026-05-20%20at%208.50.01%E2%80%AFPM.png?alt=media&amp;token=70420076-c4dc-46f1-9f51-d352326cf12e" alt=""><figcaption></figcaption></figure>

Toggle <img src="https://2449056524-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FK6BdQXak9wiY4BdSf9Rq%2Fuploads%2FeC0CTyg5Eo79AaK7Xdqd%2FScreenshot%202026-05-20%20at%208.46.57%E2%80%AFPM.png?alt=media&amp;token=fdd86e49-6104-4d5a-87f2-35eb55508756" alt="" data-size="line"> in the Grid properties to clip items in the cells, and their children, to within the Cell area.

<figure><img src="https://2449056524-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FK6BdQXak9wiY4BdSf9Rq%2Fuploads%2FfklFwQL6NqWo3Agwzy0G%2FScreenshot%202026-05-20%20at%208.48.40%E2%80%AFPM.png?alt=media&amp;token=09cdf3f7-b4d9-497c-ad70-a385248b8326" alt=""><figcaption></figcaption></figure>

***

## Cell Size & Spacing

*Cell W* adjusts the width, and *Cell H* the height of the cells. *Sp W* and *Sp H* will change the spacing between cells horizontally and vertically.

<figure><picture><source srcset="/files/KjMrl5b8rh63Px8kRaFQ" media="(prefers-color-scheme: dark)"><img src="https://2449056524-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FK6BdQXak9wiY4BdSf9Rq%2Fuploads%2FLczQ3KgYWDR95ehpAMBS%2FScreenshot%202026-05-20%20at%208.51.25%E2%80%AFPM.png?alt=media&amp;token=c31505e1-9bbe-404d-afd3-de3619eb0244" alt="" width="298"></picture><figcaption></figcaption></figure>

***

## Fill Orientation & Direction

*Fill Axis* determines which axis takes priority when adding new cells. "Horizontal" means cells will be added to fill a row before a new column is created.

<figure><picture><source srcset="/files/RGpsjjPWYmJdez7VqKc7" media="(prefers-color-scheme: dark)"><img src="https://2449056524-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FK6BdQXak9wiY4BdSf9Rq%2Fuploads%2FZL0kWgZ1lOTuYNO6e2Rx%2FScreenshot%202026-05-20%20at%208.53.28%E2%80%AFPM.png?alt=media&amp;token=2fbf98f1-c87d-46a7-a23e-265b811cb798" alt="" width="296"></picture><figcaption></figcaption></figure>

*H Dir* determines which direction rows will be filled in — Left to right or right to left. *V Dir* handles the vertical direction. Default values start at the top left, and fill to the right, then down, with the *Fill Axis* set to "Horizontal".

*H Align* and *V Align* determine where in the Grid area the starting  cell will appear. If you want cells to always be in the bottom left corner of a card, with new cells appearing to the right, set *H Align* to "Left" and *V Align* to "Lower".

<figure><img src="https://2449056524-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FK6BdQXak9wiY4BdSf9Rq%2Fuploads%2F1u6ZD8ADIexQq35fxiVg%2FScreenshot%202026-05-20%20at%208.57.40%E2%80%AFPM.png?alt=media&amp;token=f035d82d-baa2-415b-93a4-dcd7553dcabc" alt=""><figcaption></figcaption></figure>

***

## Row & Column Constraints

Adjust the *Constraints* value if you'd like to enforce a specific number of rows or columns. "Flexible" means the Grid will fill it's space based on the *Fill Axis*, and *H Dir* and *V Dir* values, before overflowing.

<figure><picture><source srcset="/files/wFQnCOadpDI96YsPl6Ah" media="(prefers-color-scheme: dark)"><img src="https://2449056524-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FK6BdQXak9wiY4BdSf9Rq%2Fuploads%2FN3KSNm3HQI6L92DHTAmc%2FScreenshot%202026-05-20%20at%209.00.26%E2%80%AFPM.png?alt=media&amp;token=32743607-ae44-403e-a792-787ee03f05bc" alt="" width="301"></picture><figcaption></figcaption></figure>

"Fixed Rows" or "Fixed Columns" allow you to define a specific number of rows or columns before the Grid will overflow. The example on the left has "Fixed Rows" with "1" row, while the example on the right is "Flexible".

<div><figure><img src="https://2449056524-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FK6BdQXak9wiY4BdSf9Rq%2Fuploads%2FkPZBVdOXCagI05ujcKgu%2FScreenshot%202026-05-20%20at%209.02.08%E2%80%AFPM.png?alt=media&amp;token=f7d27220-cf15-41a1-a322-15b46ad21170" alt=""><figcaption></figcaption></figure> <figure><img src="https://2449056524-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FK6BdQXak9wiY4BdSf9Rq%2Fuploads%2F3x3eUuVdMnP7d4iNA74b%2FScreenshot%202026-05-20%20at%208.58.53%E2%80%AFPM.png?alt=media&amp;token=e6667864-7c07-4682-b000-c6152209d36a" alt=""><figcaption></figcaption></figure></div>

***

## Visible Child Count

<figure><picture><source srcset="/files/Q6PsBzdZ4MFVk67KN5FO" media="(prefers-color-scheme: dark)"><img src="https://2449056524-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FK6BdQXak9wiY4BdSf9Rq%2Fuploads%2FwLvMJKPbOzTYHkWunFFF%2FScreenshot%202026-05-20%20at%209.02.37%E2%80%AFPM.png?alt=media&amp;token=203cd2c0-761d-4dd5-ae22-7f201e3d0c8b" alt="" width="290"></picture><figcaption></figcaption></figure>

With *Show all children* toggled on, all children will be shown with extras overflowing the Grid area. Otherwise, you can specify a number of visible children.&#x20;

Linking this value to a [Variables](/docs/design/templates-design-your-cards/variables.md) is useful in revealing a dynamic number of Cells based on the Variable, for each Card in the Deck.

{% hint style="success" %}
A child layer that is turned off is not considered a "child", and will not be displayed.&#x20;

To display an empty cell, either turn "Total Opacity" to 0 in the child Layer, or add an empty Layer as a child.
{% endhint %}

***

## Content Size Fitter

The <mark style="color:$success;">**Content Size Fitter**</mark> Component will force the Grid area to match the size of the children in the cells.

This is useful for creating an area that grows with the number of cells. In this example, the Grid has 5 children. The Grid itself has a *Outline*, *Curved Edges*, and the *Content Size Fitter* Components.

<figure><img src="https://2449056524-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FK6BdQXak9wiY4BdSf9Rq%2Fuploads%2FLSqkYgKziCOU75VvvsEu%2FScreenshot%202026-05-20%20at%209.09.45%E2%80%AFPM.png?alt=media&amp;token=5bc3109a-9d52-437a-9dbf-bcac277eea46" alt=""><figcaption></figcaption></figure>

And here is the same Grid, but with only 3 children. Note that the <mark style="color:$success;">**Pivot**</mark> of the Grid *Transform* is centered, so the area shrinks equally on the left and right.

<figure><img src="https://2449056524-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FK6BdQXak9wiY4BdSf9Rq%2Fuploads%2FoIHeIyOj1JBqaPJ7CJhJ%2FScreen%20Recording%202026-05-20%20at%209.17.45%E2%80%AFPM.gif?alt=media&amp;token=93cba5ec-b826-4321-92c8-2253da5550d1" alt=""><figcaption></figcaption></figure>

If we had set the Pivot to the left, then the Grid would shrink in only one direction, toward the Pivot.

<figure><img src="https://2449056524-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FK6BdQXak9wiY4BdSf9Rq%2Fuploads%2FKq4Xqc5MA2izyWOOYCPI%2FScreen%20Recording%202026-05-20%20at%209.15.39%E2%80%AFPM.gif?alt=media&amp;token=3514751e-85ce-4f5e-ba7f-c10f65e0edc0" alt=""><figcaption></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://cardstock-studio.gitbook.io/docs/design/templates-design-your-cards/layers/grids.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.
