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 — so your game's UI can look like any of these without changing a line of control code:






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 for the full gallery and usage.
Introduction
This tutorial walks you through turning an empty MonoGame or Raylib project into a code-only Gum project, which acts as a starting point for the rest of the tutorials.
This tutorial covers:
Adding Gum NuGet packages
Adding the code to initialize, update, and draw Gum
Adding your first Gum control (Button)
Everything after you have a root container is identical across MonoGame and Raylib. The only part that differs is the host application skeleton on this Setup page — once Gum is initialized, the rest of the tutorial series is fully shared.
Adding Gum NuGet Packages
Before writing any code, add the Gum NuGet package for your platform.
Add the Gum.MonoGame package to your game. For more information see the MonoGame/KNI/FNA setup page.
Once you are finished, your game project should reference the Gum.MonoGame package.

Add the Gum.raylib package to your game (https://www.nuget.org/packages/Gum.raylib). For more information see the raylib setup page.
Modify csproj:
<PackageReference Include="Gum.raylib" />Or add through the command line:
dotnet add package Gum.raylibAdding Gum to Your Game
Gum requires a few lines of code to get started. The host application skeleton differs by platform — MonoGame uses a Game subclass whose Initialize/Update/Draw methods the framework calls for you, while Raylib uses a Program.Main with a game loop you own. The Gum calls themselves are the same on both backends: initialize once, then update and draw each frame.
A simplified host with the required calls would look like the following code:
The code above includes the following sections:
Initialize - the initialization code prepares Gum for use. It must be called one time for every Gum project. Once Gum is initialized, we can create controls such as the
StackPanelwhich contains all other controls. By callingAddToRoot, themainPanelis drawn and receives input. All items added to theStackPanelwill also be drawn and receive input, so we only need to callAddToRooton theStackPanel.
Update - this updates the internal keyboard, mouse, and gamepad instances and applies default behavior to any forms components. For example, if a
Buttonis added to theStackPanel, this code is responsible for checking if the cursor is overlapping theButtonand adjusting the highlight/pressed state appropriately.Draw - this draws all Gum objects to the screen. This does not yet perform any drawing since
StackPanelsare invisible, but we'll be adding controls later in this tutorial.
We can run our project to see a blank screen filled with the clear color.

Adding Controls
Now that we have Gum running, we can add controls to our StackPanel (mainPanel). The following code adds a Button which responds to being clicked by modifying its Text property. Add it right after mainPanel is created:

Conclusion
Now that we have a basic project set up with a single Button. The next tutorial covers the most common forms controls.
Last updated
Was this helpful?

