> 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/styling/code-only-styling/styling-using-activestyles.md).

# Styling Using ActiveStyles

{% hint style="info" %}
This document assumes using V3 styles, which were introduced at the end of November 2025. If your project is using V2 visuals, you need to upgrade to V3 before the styling discussed on this document can be used.

For information on upgrading, see the [Migrating to 2025 November](https://docs.flatredball.com/gum/gum-tool/upgrading/migrating-to-2025-november.md) page.
{% endhint %}

## Introduction

Gum can be restyled using an `ActiveStyle` object. Changes to `ActiveStyle` result in style changes for all controls created after the change is made. `ActiveStyle` can make it easy to restyle all controls without needing to make changes to each individual control.

If you are using a Gum project with Forms components, `ActiveStyle` does not restyle controls whose visuals come from your project. See [Gum Tool Styling and the Styling Object](https://docs.flatredball.com/gum/code/styling/control-customization-in-gum-tool.md#gum-tool-styling-and-the-styling-object) for how the two relate.

## Styling.ActiveStyle.Colors

Gum includes a `Styling` object which contains multiple color values for default styling. For example the `Primary` color can be changed using the following code:

```csharp
// Initialize
Styling.ActiveStyle.Colors.Primary = Color.DarkGreen;
```

The following properties exist on Colors:

<table><thead><tr><th width="212.18182373046875">Colors Property</th><th>Used By</th></tr></thead><tbody><tr><td>Primary</td><td><ul><li>Button Background</li><li>CheckBox Background</li><li>ComboBox DropdownIndicator</li><li>ListBoxItem Background (Selected)</li><li>MenuItem Background (Selected)</li><li>RadioButton Background</li><li>Slider Thumb Background</li><li>TextBox Caret</li><li>Window Background (Default only border)</li></ul></td></tr><tr><td>Warning</td><td><ul><li>FocusIndicators on all controls</li></ul></td></tr><tr><td>Accent</td><td><ul><li>ListBoxItem Background (Highlight)</li><li>MenuItem Background (Highlight)</li></ul></td></tr><tr><td>InputBackground</td><td><ul><li>ComboBox Background</li><li>ListBox Background</li><li>Menu Background</li><li>PasswordBox Background</li><li>ScrollViewer Background</li><li>Slider Track Background</li><li>Splitter Background</li><li>TextBox Background</li></ul></td></tr><tr><td>SurfaceVariant</td><td><ul><li>ScrollBar Track Background</li></ul></td></tr><tr><td>IconDefault</td><td><ul><li>CheckBox Check</li><li>RadioButton Radio</li><li>ScrollBar UpButton/DownButton Icon</li></ul></td></tr><tr><td>TextPrimary</td><td><ul><li>Button Text</li><li>CheckBox Text</li><li>ComboBox Text</li><li>Label</li><li>ListBoxItem Text</li><li>MenuItem Text</li><li>MenuItem SubmenuIndicator</li><li>PasswordBox Text</li><li>RadioButton Text</li><li>TextBox Text</li></ul></td></tr><tr><td>TextMuted</td><td><ul><li>PasswordBox PlaceholderTextInstance</li><li>TextBox PlaceholderTextInstance</li></ul></td></tr></tbody></table>

## Code Example: Applying Styles Before Creating Controls

The `Styling.ActiveStyle.Color` property includes styles that are used by controls when they are created. We can see how these affect controls by creating a sample project:

```csharp
// Initialize
var window = new Window();
window.AddToRoot();
window.Anchor(Anchor.Center);
window.Width = 270;
window.MinWidth = 270;
window.Height = 400;
window.MinHeight = 400;

var windowVisual = (WindowVisual)window.Visual;

var stackPanel = new StackPanel();
window.AddChild(stackPanel);
stackPanel.Dock(Dock.Top);
stackPanel.Y = window.TitleHeight;
stackPanel.Width = -16;

var button = new Button();
var buttonVisual = (Gum.Forms.DefaultVisuals.V3.ButtonVisual)button.Visual;
stackPanel.AddChild(button);

var checkBox = new CheckBox();
stackPanel.AddChild(checkBox);

var comboBox = new ComboBox();
stackPanel.AddChild(comboBox);
for(int i = 0; i < 10; i++)
{
    comboBox.Items.Add($"ComboBox Item {i}");
}

var listBox = new ListBox();
stackPanel.AddChild(listBox);
listBox.Height = 200;
for(int i = 0; i < 20; i++)
{
    listBox.Items.Add($"Item {i}");
}

var radioButton1 = new RadioButton();
stackPanel.AddChild(radioButton1);
radioButton1.Text = "Option 1";

var radioButton2 = new RadioButton();
stackPanel.AddChild(radioButton2);
radioButton2.Text = "Option 2";

var textBox = new TextBox();
stackPanel.AddChild(textBox);
```

This code produces a set of controls which can be used to check how styling is applied.

{% columns %}
{% column %}

<figure><img src="https://2695663588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fzQmxQ1VeUFHcoo2c%2Fuploads%2Fgit-blob-cc40d3afe53dc4011bbe1541461eea3b62feb520%2F25_21%2023%2015.png?alt=media" alt=""><figcaption><p>Controls using default styles</p></figcaption></figure>
{% endcolumn %}

{% column %}

<figure><img src="https://2695663588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fzQmxQ1VeUFHcoo2c%2Fuploads%2Fgit-blob-9bbe66bb1795fe1ac18c049ddb30551872e300fa%2Fstyling_example_no_color_changes.gif?alt=media" alt="Controls using default styles (Animated)"><figcaption><p>Controls using default styles (Animated)</p></figcaption></figure>
{% endcolumn %}
{% endcolumns %}

We can prefix the following code before creating all of our controls:

```csharp
// Initialize
Styling.ActiveStyle.Colors.Primary = Color.DarkGreen;
Styling.ActiveStyle.Colors.InputBackground = Color.Black;
Styling.ActiveStyle.Colors.TextPrimary = Color.LimeGreen;
Styling.ActiveStyle.Colors.Accent = Color.Yellow;

// Create controls here:
```

By changing these colors, controls are created using the new colors:

{% columns %}
{% column %}

<figure><img src="https://2695663588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fzQmxQ1VeUFHcoo2c%2Fuploads%2Fgit-blob-4c260bac7c28a9bc02322dec2d1a37a6c22b2a3d%2F25_21%2034%2056.png?alt=media" alt="Colors changed with minimal code"><figcaption><p>Colors changed with minimal code</p></figcaption></figure>
{% endcolumn %}

{% column %}

<figure><img src="https://2695663588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fzQmxQ1VeUFHcoo2c%2Fuploads%2Fgit-blob-34033b48e6b12f3ae971eab069fc773cebeb0337%2Fstyling_example_with_color_changes.gif?alt=media" alt=""><figcaption><p>All Styling behaviors remain (darken/lighten)</p></figcaption></figure>
{% endcolumn %}
{% endcolumns %}

## Styling and Fonts

Just as `Styling.ActiveStyle.Colors` controls the colors of every control created after it is set, `Styling.ActiveStyle.Text` controls their fonts — so a single assignment restyles text across the entire project without modifying individual controls. It exposes three text states:

* `Normal` — the default font, applied to the text of most controls (`Button`, `Label`, `TextBox`, `ListBoxItem`, and so on).
* `Strong` — a bold variant, applied by `ComboBox`.
* `Emphasis` — an italic variant (not applied by the built-in controls; available when you apply it to your own text).

Set the `Font`, `FontSize`, `IsBold`, or `IsItalic` values on a state to change it. The following code relies on KernSmith for dynamic font creation. For more information on dynamic fonts and information on using KernSmith, see the [Font Strategies](https://docs.flatredball.com/gum/code/files-and-fonts/fonts/font-strategies.md#dynamic-kernsmith-generation) page.

{% hint style="info" %}
Available in preview NuGet packages (use a `-preview` version), or now if building Gum from source.
{% endhint %}

```csharp
// Initialize
GumUI.UseKernSmith();

var textStyling = Gum.Forms.DefaultVisuals.V3.Styling.ActiveStyle.Text;
var normalState = textStyling.Normal;
normalState.SetValue("Font", "Consolas", "string");
normalState.SetValue("FontSize", 28, "int");

var button = new Button();
button.AddToRoot();
button.Anchor(Anchor.Center);
```

<figure><img src="https://2695663588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fzQmxQ1VeUFHcoo2c%2Fuploads%2Fgit-blob-b27342c007789dbf97cc5dae650226baecdfcb85%2F18_04%2059%2005.png?alt=media" alt=""><figcaption><p>Button using larger Consolas font</p></figcaption></figure>

## Styling and Creation Order

Styling only applies after it has been set. Controls which are created before styling is set do not automatically update to the new style. The following code shows how order can impact how styling is assigned:

```csharp
// Initialize
var stackPanel = new StackPanel();
stackPanel.AddToRoot();
stackPanel.Anchor(Anchor.Center);

var button1 = new Button();
stackPanel.AddChild(button1);

Styling.ActiveStyle.Colors.Primary = Color.Red;

var button2 = new Button();
stackPanel.AddChild(button2);

Styling.ActiveStyle.Colors.Primary = Color.Purple;

var button3 = new Button();
stackPanel.AddChild(button3);

```

<figure><img src="https://2695663588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fzQmxQ1VeUFHcoo2c%2Fuploads%2Fgit-blob-b6f0384e12ad33a32564717d8cac30100a09fe6b%2F26_06%2027%2042.png?alt=media" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
This behavior may change in future versions of Gum.
{% endhint %}


---

# 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/styling/code-only-styling/styling-using-activestyles.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.
