> 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/formulas-in-text-number-fields.md).

# Formulas in Text / Number Fields

In addition to using [Text Style Presets](/docs/design/text-style-presets.md) , [Global Values](/docs/design/global-values.md), [Images](/docs/design/images.md), [Shapes](/docs/design/shapes.md) and [Prefabs](/docs/design/prefabs.md) in text fields, you can write formulas as well.

This works in `string` fields and `number` fields, such as the Transform position and width values.

{% hint style="info" %}
In all of these examples, use `<this>` instead of the current layers name to refer to the current layers properties.
{% endhint %}

{% hint style="info" %}
Boolean variables which resolve `true` or `false` will resolve as `1` or `0` respectively when used in formulas.
{% endhint %}

***

## Example 1

<div><figure><img src="https://2449056524-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FK6BdQXak9wiY4BdSf9Rq%2Fuploads%2FVfOumwoBtnSFsV8EqICQ%2FScreenshot%202026-08-06%20at%203.15.24%E2%80%AFPM.png?alt=media&amp;token=2142f87d-2095-44f1-9da3-ce7b79c55e31" alt=""><figcaption></figcaption></figure> <figure><img src="https://2449056524-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FK6BdQXak9wiY4BdSf9Rq%2Fuploads%2F4oYZZBAbUzYdCsdsdgZx%2FScreenshot%202026-08-06%20at%203.15.29%E2%80%AFPM.png?alt=media&amp;token=494726a4-a334-4299-8d5f-76ef6c8cd91b" alt=""><figcaption></figcaption></figure></div>

In the example above, the "Star" layer has a [Conditionals](/docs/design/templates-design-your-cards/conditionals.md) set to "Always Apply", which uses the formula:

&#x20;`{= <Attack Value.x> + <Attack Value.width> }`

"*Attack Value*" is another layer.&#x20;

***

## Example 2

<div><figure><img src="https://2449056524-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FK6BdQXak9wiY4BdSf9Rq%2Fuploads%2FEfINqIbgd0Gb48nSq3UT%2FScreenshot%202026-08-06%20at%203.20.34%E2%80%AFPM.png?alt=media&amp;token=c10e26c0-c6b6-4e79-bbde-74872681250c" alt=""><figcaption></figcaption></figure> <figure><img src="https://2449056524-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FK6BdQXak9wiY4BdSf9Rq%2Fuploads%2Fb6J37HCV1GHWdBRx7viL%2FScreenshot%202026-08-06%20at%203.20.37%E2%80%AFPM.png?alt=media&amp;token=13674438-dce2-4ae2-aa74-5242bf96d641" alt="" width="563"><figcaption></figcaption></figure></div>

In this example, the *Cost* variable is 12 (see the bottom right of the card). For demonstration purposes, I've updated the content of the text to be:

`{= <Cost> * 2 }`

This resolves to 24.


---

# 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/formulas-in-text-number-fields.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.
