> 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/code/getting-started/tutorials/code-only-gum-forms-tutorial/setup.md). Agents can also search and read this documentation through its [MCP server](https://docs.flatredball.com/gum/~gitbook/mcp).

# Setup

Gum Forms gives you a full set of UI controls in code, and a single line restyles **every** control with a built-in theme; your game's UI can look like any of these without changing a line of control code:

|                                                                                                                                DarkPro                                                                                                                                |                                                                                                                                 Bubblegum                                                                                                                                 |                                                                                                                               Neon                                                                                                                              |
| :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
| <img src="https://2695663588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fzQmxQ1VeUFHcoo2c%2Fuploads%2Fgit-blob-7406d6fe27c9ff29f694180f4fcbbb4961f9901c%2FDarkProThemeScreenshot.png?alt=media" alt="DarkPro theme" data-size="original"> | <img src="https://2695663588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fzQmxQ1VeUFHcoo2c%2Fuploads%2Fgit-blob-ff9f4de7cfbdda96b94a0491037516ca4d1a7e47%2FBubblegumThemeScreenshot.png?alt=media" alt="Bubblegum theme" data-size="original"> | <img src="https://2695663588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fzQmxQ1VeUFHcoo2c%2Fuploads%2Fgit-blob-bdb1de8632f04b6888aa1cbfe3197ba9b731126c%2FNeonThemeScreenshot.png?alt=media" alt="Neon theme" data-size="original"> |

|                                                                                                                                Retro 95                                                                                                                               |                                                                                                                                  Forest Glade                                                                                                                                  |                                                                                                                                Editor                                                                                                                               |
| :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
| <img src="https://2695663588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fzQmxQ1VeUFHcoo2c%2Fuploads%2Fgit-blob-629d8df32195584bee134d6dba53b697d3fcda98%2FRetro95ThemeScreenshot.png?alt=media" alt="Retro95 theme" data-size="original"> | <img src="https://2695663588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fzQmxQ1VeUFHcoo2c%2Fuploads%2Fgit-blob-bb3e07ad48d2120bcc82034fb939c6ff051b9162%2FForestGladeThemeScreenshot.png?alt=media" alt="Forest Glade theme" data-size="original"> | <img src="https://2695663588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fzQmxQ1VeUFHcoo2c%2Fuploads%2Fgit-blob-6fed8bfa460634ee57face837ba0ca6c2fa80031%2FEditorThemeScreenshot.png?alt=media" alt="Editor theme" data-size="original"> |

This tutorial uses Gum's default visuals to keep the dependency footprint minimal, but you can drop in any of the themes above (or author your own) with one `Apply` call. See the [Themes reference](https://docs.flatredball.com/gum/code/styling/themes.md) for the full gallery and usage.

## Introduction

This tutorial creates a code-only Gum project with a single `Button`, which acts as a starting point for the rest of the tutorials. Only this page depends on your runtime. Once Gum is initialized, the rest of the tutorial series is the same on every runtime.

## Adding Gum to Your Project

Follow the setup page for your runtime through its full program, which ends with a working `Button`:

* [MonoGame/KNI/FNA](https://docs.flatredball.com/gum/code/getting-started/setup/adding-initializing-gum/monogame-kni-fna.md)
* [KNI with Skia](https://docs.flatredball.com/gum/code/getting-started/setup/adding-initializing-gum/kni-skia.md)
* [raylib (raylib-cs)](https://docs.flatredball.com/gum/code/getting-started/setup/adding-initializing-gum/raylib-raylib-cs.md)
* [Silk.NET](https://docs.flatredball.com/gum/code/getting-started/setup/adding-initializing-gum/silk.net.md)
* [BRUTAL](https://docs.flatredball.com/gum/code/getting-started/setup/adding-initializing-gum/brutal.md)
* [Stride](https://docs.flatredball.com/gum/code/getting-started/setup/adding-initializing-gum/stride.md)
* [Unity](https://docs.flatredball.com/gum/code/getting-started/setup/adding-initializing-gum/unity.md)

Then return here to continue.

## Adding a StackPanel

The rest of this tutorial series adds controls to a `StackPanel` named `mainPanel`. Replace the `Button` code from your setup page with the following code, placed right after `GumUI.Initialize` (in Unity, inside `Start`). `AddToRoot` makes `mainPanel` draw and receive input, along with everything added to it.

```csharp
// Initialize
var mainPanel = new StackPanel();
mainPanel.AddToRoot();

// Creates a button instance
var button = new Button();
// Adds the button as a child so that it is drawn and has its
// events raised
mainPanel.AddChild(button);
// Initial button text before being clicked
button.Text = "Click Me";
// Makes the button wider so the text fits
button.Width = 350;
// Click event can be handled with a lambda
button.Click += (_, _) =>
    button.Text = $"Clicked at {System.DateTime.Now}";
```

[Try on XnaFiddle.NET](https://xnafiddle.net/#snippet=H4sIAAAAAAAAA12NSwvCMBCE_8oSPFSQUBQvSg--EA-KaNGLINEsdGmagN34xP9uH6LibWfmm9mHmOVTn4kenzy2BFliUobuKHrirE6QKbJLZdFABBYvsGZ1TCsjaPZ39hPLDeVeGTnQOnYr57iKy4WDZ3b2XR9W4q9adEYJGR3UaBnWl4zxykVz58Ow3R4ZOqYwx1p9oS1pTgqq0w2_Zg1X6DCCYN-CfROiUncm__ONn33UoBge61vOmMmxYowpQ7lwl-f7r3i-AEs5ZmU0AQAA)

<figure><img src="https://2695663588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fzQmxQ1VeUFHcoo2c%2Fuploads%2Fgit-blob-803b82ad63b5887309d839fc09005e6cdbfc39b3%2F13_07%2003%2009.gif?alt=media" alt=""><figcaption></figcaption></figure>

## Conclusion

We now have a basic project with a single `Button` in a `StackPanel`. The next tutorial covers the most common forms controls.


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.flatredball.com/gum/code/getting-started/tutorials/code-only-gum-forms-tutorial/setup.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
