> 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/components/content-size-fitter.md).

# Content Size Fitter

<mark style="color:$success;">**Content Size Fitter**</mark> will resize the Transform of a Layer to fit the size of it's children. There is an optional padding that can be applied to each direction independently as well.

<figure><img src="https://2449056524-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FK6BdQXak9wiY4BdSf9Rq%2Fuploads%2FhFGP42845iTwBA4YX6rP%2FScreen%20Recording%202026-05-20%20at%2010.06.14%E2%80%AFPM.gif?alt=media&amp;token=01a250a7-640f-4cc6-b815-d144f8cd7781" alt=""><figcaption></figcaption></figure>

Here the a black Rectangle grows when the Text layer moves.

Only direct children will affect the Transform size.

***

## Grids and Content Size Fitter

The Content Size Fitter works really well with [Grids](/docs/design/templates-design-your-cards/layers/grids.md). This enables the Grid transform to grow and shrink with the number of cells in the grid.

You can also stack Layers together, with multiple Content Size Fitter components, as in the example below.

<figure><img src="https://2449056524-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FK6BdQXak9wiY4BdSf9Rq%2Fuploads%2FEw95ewtSuauf5FS4JVDn%2FScreenshot%202026-06-03%20at%208.47.43%E2%80%AFPM.png?alt=media&amp;token=35a70a28-4249-4ea3-adc5-2d22e9aef91b" alt="" width="245"><figcaption></figcaption></figure>

Here, both the *Custom Shape* and *Gems Grid* have a Content Size Fitter component on them. The Grid has 6 children. With the Content Size Fitter, it will shrink if we toggle off some of the gems.

<div><figure><img src="https://2449056524-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FK6BdQXak9wiY4BdSf9Rq%2Fuploads%2F8WBpGQutuucFoYfjnrQ7%2FScreenshot%202026-06-03%20at%208.48.03%E2%80%AFPM.png?alt=media&amp;token=1375d2ff-7e5a-4236-ab0b-f7c1d261b241" alt="" width="375"><figcaption></figcaption></figure> <figure><img src="https://2449056524-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FK6BdQXak9wiY4BdSf9Rq%2Fuploads%2FPescsttYaNqRLgY8CjSN%2FScreenshot%202026-06-03%20at%208.48.13%E2%80%AFPM.png?alt=media&amp;token=1390f72e-c552-4c32-8121-d488ad4d3703" alt="" width="375"><figcaption></figcaption></figure></div>

Since the *Custom Shape* also has a Content Size FItter, it will also shrink with the Grid. We use the *Padding* values in the *Custom Shape* to give some space around the grid for the wedge arrow.

<div><figure><img src="https://2449056524-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FK6BdQXak9wiY4BdSf9Rq%2Fuploads%2FxsniqQojgPQQhhxyfmRf%2FScreenshot%202026-06-03%20at%208.52.04%E2%80%AFPM.png?alt=media&amp;token=f6de642f-3753-4f00-b806-a925896d7f6a" alt=""><figcaption></figcaption></figure> <figure><img src="https://2449056524-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FK6BdQXak9wiY4BdSf9Rq%2Fuploads%2F3GX0CKwPVrjWD3F97r0L%2FScreenshot%202026-06-03%20at%208.52.13%E2%80%AFPM.png?alt=media&amp;token=3077ab8d-ec05-487d-bd8c-2e6880bdde38" alt=""><figcaption></figcaption></figure></div>


---

# 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/components/content-size-fitter.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.
