ktsu.ThemeProvider 3.0.7

Prefix Reserved
dotnet add package ktsu.ThemeProvider --version 3.0.7
                    
NuGet\Install-Package ktsu.ThemeProvider -Version 3.0.7
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ktsu.ThemeProvider" Version="3.0.7" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ktsu.ThemeProvider" Version="3.0.7" />
                    
Directory.Packages.props
<PackageReference Include="ktsu.ThemeProvider" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ktsu.ThemeProvider --version 3.0.7
                    
#r "nuget: ktsu.ThemeProvider, 3.0.7"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package ktsu.ThemeProvider@3.0.7
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=ktsu.ThemeProvider&version=3.0.7
                    
Install as a Cake Addin
#tool nuget:?package=ktsu.ThemeProvider&version=3.0.7
                    
Install as a Cake Tool

ktsu.ThemeProvider

A semantic color theming library for .NET applications with 38 themes, intelligent color mapping, and framework integration.

License NuGet Version NuGet Version NuGet Downloads GitHub commit activity GitHub contributors GitHub Actions Workflow Status

Introduction

ktsu.ThemeProvider is a comprehensive theming system that uses semantic color specifications rather than arbitrary color names. Instead of hardcoding colors like "blue" or "red", you define colors by their purpose (Primary, Error, Warning) and priority level, and the library generates consistent, accessible color palettes. It includes 38 carefully crafted themes from popular color schemes and provides built-in Dear ImGui integration with an extensible architecture for other UI frameworks.

Features

  • Semantic Color System: Define colors by purpose (Primary, Error, Warning, Neutral) and priority level rather than specific hues, enabling consistent theming across any UI framework
  • 38 Built-in Themes: Includes Catppuccin, Tokyo Night, Gruvbox, Everforest, Nightfox, Kanagawa, PaperColor, Nord, Dracula, VSCode, One Dark, Monokai, and Nightfly theme families
  • Centralized Theme Registry: Discover, filter, and instantiate themes by name, family, or light/dark classification with rich metadata
  • Dear ImGui Integration: Companion package ktsu.ThemeProvider.ImGui provides complete ImGui color palette mapping via ImGuiPaletteMapper
  • Perceptual Color Science: Uses Oklab perceptual color space for uniform color interpolation, extrapolation, and lightness-based priority mapping
  • WCAG Accessibility: Built-in contrast ratio calculations, accessibility level checking (AA/AAA), and automatic color adjustment to meet WCAG standards
  • Extensible Framework Mappers: Implement IPaletteMapper<TColorKey, TColorValue> to integrate with any UI framework
  • Priority-Based Color Hierarchy: Seven priority levels (VeryLow to VeryHigh) automatically mapped to appropriate lightness values, with theme-aware ordering for dark and light themes
  • Multi-Target Support: Targets .NET 5.0 through 10.0, plus .NET Standard 2.0 and 2.1

Installation

Package Manager Console

Install-Package ktsu.ThemeProvider

.NET CLI

dotnet add package ktsu.ThemeProvider

Package Reference

<PackageReference Include="ktsu.ThemeProvider" Version="x.y.z" />

For Dear ImGui integration, also install:

dotnet add package ktsu.ThemeProvider.ImGui

Usage Examples

Basic Example

using ktsu.ThemeProvider;
using static ktsu.ThemeProvider.ThemeRegistry;

// Create a theme directly
var theme = new Themes.Catppuccin.Mocha();

// Or find and create via the registry
ThemeInfo? themeInfo = FindTheme("Catppuccin Mocha");
ISemanticTheme? registryTheme = themeInfo?.CreateInstance();

// Map semantic color requests to actual colors
var requests = new[]
{
    new SemanticColorRequest(SemanticMeaning.Primary, Priority.Medium),
    new SemanticColorRequest(SemanticMeaning.Error, Priority.High),
    new SemanticColorRequest(SemanticMeaning.Neutral, Priority.VeryLow),
};
IReadOnlyDictionary<SemanticColorRequest, Color> colors =
    SemanticColorMapper.MapColors(requests, theme);

Theme Discovery with the Registry

using ktsu.ThemeProvider;
using static ktsu.ThemeProvider.ThemeRegistry;

// Browse all themes
IReadOnlyList<ThemeInfo> allThemes = AllThemes;
IReadOnlyList<ThemeInfo> darkThemes = DarkThemes;
IReadOnlyList<ThemeInfo> lightThemes = LightThemes;

// Browse by family
IReadOnlyList<string> families = Families;
IReadOnlyList<ThemeInfo> catppuccinThemes = GetThemesInFamily("Catppuccin");

// Find a specific theme by name (case-insensitive)
ThemeInfo? themeInfo = FindTheme("Tokyo Night Storm");
ISemanticTheme? theme = themeInfo?.CreateInstance();

// Create all theme instances at once
IReadOnlyList<ISemanticTheme> allInstances = CreateAllThemeInstances();
IReadOnlyList<ISemanticTheme> gruvboxInstances = CreateThemeInstancesInFamily("Gruvbox");

Complete Palette Generation

using ktsu.ThemeProvider;
using ktsu.Semantics.Color;

var theme = new Themes.Nord.Nord();

// Generate the complete palette (all meaning + priority combinations)
IReadOnlyDictionary<SemanticColorRequest, Color> completePalette =
    SemanticColorMapper.MakeCompletePalette(theme);

// Access any color from the palette
var primaryMedium = completePalette[new SemanticColorRequest(SemanticMeaning.Primary, Priority.Medium)];
string hex = primaryMedium.ToHex();

Dear ImGui Integration

using ktsu.ThemeProvider;
using ktsu.ThemeProvider.ImGui;
using Hexa.NET.ImGui;

// Create theme and mapper
var theme = new Themes.Catppuccin.Mocha();
var mapper = new ImGuiPaletteMapper();

// Get complete ImGui color palette
IReadOnlyDictionary<ImGuiCol, Vector4> imguiColors = mapper.MapTheme(theme);

// Apply to ImGui style
var style = ImGui.GetStyle();
foreach ((ImGuiCol colorKey, Vector4 colorValue) in imguiColors)
{
    style.Colors[(int)colorKey] = colorValue;
}

Accessibility Checking

using ktsu.ThemeProvider;
using ktsu.Semantics.Color;

Color foreground = Color.FromHex("#FFFFFF");
Color background = Color.FromHex("#1E1E2E");

// Calculate contrast ratio (1.0 .. 21.0)
double contrastRatio = foreground.ContrastRatio(background);

// Check WCAG compliance
AccessibilityLevel level = foreground.AccessibilityLevelAgainst(background, largeText: false);

// Adjust a color to meet accessibility requirements
Color adjusted = foreground.AdjustForContrast(background, AccessibilityLevel.AA);

// Create perceptually uniform gradients
IReadOnlyList<Color> gradient = foreground.Gradient(background, steps: 10);

Advanced Usage

Creating Custom Framework Mappers

Implement IPaletteMapper<TColorKey, TColorValue> to integrate with any UI framework:

using ktsu.ThemeProvider;

public class MyFrameworkMapper : IPaletteMapper<MyColorEnum, MyColorType>
{
    public string FrameworkName => "My UI Framework";

    public IReadOnlyDictionary<MyColorEnum, MyColorType> MapTheme(ISemanticTheme theme)
    {
        var requests = new Dictionary<MyColorEnum, SemanticColorRequest>
        {
            { MyColorEnum.Button, new(SemanticMeaning.Primary, Priority.Medium) },
            { MyColorEnum.Background, new(SemanticMeaning.Neutral, Priority.VeryLow) },
            { MyColorEnum.ErrorText, new(SemanticMeaning.Error, Priority.High) },
        };

        var palette = SemanticColorMapper.MapColors(requests.Values, theme);

        var result = new Dictionary<MyColorEnum, MyColorType>();
        foreach (var kvp in requests)
        {
            if (palette.TryGetValue(kvp.Value, out var color))
            {
                result[kvp.Key] = ConvertToMyColor(color.RgbValue);
            }
        }
        return result;
    }
}

Creating Custom Themes

Declare your palette as a SemanticPalette and let it build the mapping. Colors are written as hex strings, the notation upstream color schemes publish, so a theme can be diffed against its source:

using ktsu.ThemeProvider;
using ktsu.Semantics.Color;
using System.Collections.ObjectModel;

public class MyCustomTheme : ISemanticTheme
{
    private static readonly SemanticPalette Palette = new()
    {
        // Neutrals are a ramp; the mapper interpolates between them across priority levels.
        Neutrals = ["#C0CAF5", "#1A1B26"],
        Primary = "#7AA2F7",
        Alternate = "#BB9AF7",
        Success = "#9ECE6A",
        CallToAction = "#9ECE6A",
        Information = "#7DCFFF",
        Caution = "#FF9E64",
        Warning = "#E0AF68",
        Error = "#F7768E",
        Failure = "#F7768E",
        Debug = "#BB9AF7",
    };

    public Dictionary<SemanticMeaning, Collection<Color>> SemanticMapping => Palette.ToSemanticMapping();

    public bool IsDarkTheme => true;
}

SemanticMapping is the only contract, so a theme with unusual needs (more than two neutrals, or a meaning driven by something other than a fixed hex) can still build the dictionary itself.

API Reference

SemanticMeaning (enum)

Defines semantic color purposes.

Value Description
Neutral Backgrounds, borders, inactive elements
Primary Main brand/accent colors
Alternate Secondary accent, binary choice emphasis
Success Successful operations, confirmations
CallToAction Important buttons and highlights demanding attention
Information Informational content, help text
Caution Cautionary content needing attention
Warning Warning states, potentially problematic
Error Error states, incorrect conditions
Failure Failed operations (distinct from error)
Debug Debug/development information

Priority (enum)

Controls color intensity and lightness within a semantic meaning.

Value Description
VeryLow Lowest intensity (backgrounds in dark themes, lightest in light themes)
Low Low intensity
MediumLow Below-medium intensity
Medium Default intensity level
MediumHigh Above-medium intensity
High High intensity
VeryHigh Highest intensity (foreground text in dark themes, darkest in light themes)

SemanticColorRequest

A readonly record struct combining a SemanticMeaning and Priority to specify a color.

Property Type Description
Meaning SemanticMeaning The semantic purpose of the color
Priority Priority The intensity/lightness level

SemanticColorMapper

Static class that maps semantic color requests to actual colors.

Methods
Name Return Type Description
MapColors(requests, theme) IReadOnlyDictionary<SemanticColorRequest, Color> Maps a collection of requests to colors using the theme
MakeCompletePalette(theme) IReadOnlyDictionary<SemanticColorRequest, Color> Generates all possible meaning+priority combinations for a theme

ThemeRegistry

Static class providing centralized theme discovery and management.

Properties
Name Type Description
AllThemes IReadOnlyList<ThemeInfo> All 38 registered themes with metadata
DarkThemes IReadOnlyList<ThemeInfo> All dark themes
LightThemes IReadOnlyList<ThemeInfo> All light themes
Families IReadOnlyList<string> All theme family names
ThemesByFamily IReadOnlyDictionary<string, IReadOnlyList<ThemeInfo>> Themes grouped by family
Methods
Name Return Type Description
FindTheme(name) ThemeInfo? Finds a theme by name (case-insensitive)
GetThemesInFamily(family) IReadOnlyList<ThemeInfo> Gets all themes in a family
CreateAllThemeInstances() IReadOnlyList<ISemanticTheme> Creates instances of all themes
CreateThemeInstancesInFamily(family) IReadOnlyList<ISemanticTheme> Creates instances of themes in a family

Color types (ktsu.Semantics.Color)

Colors are represented by the Color type from the ktsu.Semantics.Color package (linear RGB + alpha, gamma-correct). It is the currency type for themes (ISemanticTheme.SemanticMapping) and SemanticColorMapper.

Common members:

Member Description
Color.FromHex(hex) Creates a color from an sRGB hex string (proper sRGB→linear decode)
ToHex() / ToBytes() Converts back to an sRGB hex string / 8-bit channels
ToSrgbVector4() sRGB-encoded Vector4 for UI frameworks (e.g. ImGui)
ToOklab() / ToOklch() Perceptual (Oklab / polar LCh) representations
ContrastRatio(other) WCAG contrast ratio (1:1 .. 21:1)
AccessibilityLevelAgainst(bg, largeText) WCAG AA/AAA compliance (returns AccessibilityLevel)
AdjustForContrast(bg, level, largeText) Adjusts lightness to meet a WCAG level
DistanceTo(other) Perceptual (Oklab) distance
MixOklab(other, t) / Gradient(to, steps) Perceptual blend / uniform gradient

Migration note (v2.0): ThemeProvider's in-house RgbColor, SRgbColor, OklabColor, PerceptualColor, and ColorMath types were removed in favour of ktsu.Semantics.Color. This also fixed a long-standing sRGB-as-linear gamma bug — base theme colors render identically, but the semantic mapper's derived colors and accessibility numbers are now computed correctly.

IPaletteMapper<TColorKey, TColorValue>

Interface for mapping semantic themes to framework-specific color palettes.

Properties
Name Type Description
FrameworkName string The name of the target UI framework
Methods
Name Return Type Description
MapTheme(theme) IReadOnlyDictionary<TColorKey, TColorValue> Maps a theme to a framework-specific palette

Available Themes

Family Variants Description
Catppuccin Latte, Frappe, Macchiato, Mocha Warm pastel themes with excellent readability
Tokyo Night Night, Storm, Day Clean themes inspired by Tokyo's neon nights
Gruvbox Dark, Dark Hard, Dark Soft, Light, Light Hard, Light Soft Retro groove colors with warm backgrounds
Everforest Dark, Dark Hard, Dark Soft, Light, Light Hard, Light Soft Green forest colors for comfortable viewing
Nightfox Nightfox, Dayfox, Duskfox, Nordfox, Terafox, Carbonfox, Dawnfox Fox-inspired vibrant themes
Kanagawa Wave, Dragon, Lotus Japanese-inspired themes
PaperColor Light, Dark Material Design inspired themes
VSCode Dark, Light Microsoft VSCode default themes
Nord - Arctic-inspired theme with cool blue tones
Dracula - Gothic theme with purple and pink accents
One Dark - Atom's iconic One Dark theme
Monokai - Classic Monokai with vibrant colors
Nightfly - Dark blue theme inspired by night flying

Contributing

Contributions are welcome! Feel free to open issues or submit pull requests.

License

This project is licensed under the MIT License. See the LICENSE.md file for details.

Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on ktsu.ThemeProvider:

Package Downloads
ktsu.ImGuiStyler

A library for expressively styling ImGui.NET interfaces.

ktsu.ThemeProvider.ImGui

A semantic color theming library for .NET applications that provides 44+ beautiful themes with intelligent color mapping, framework integration, and accessibility-first design. Features include theme discovery through a centralized registry, semantic color specifications (meaning + priority instead of hardcoded colors), built-in Dear ImGui support, and advanced color science with perceptually uniform color spaces.

ktsu.ImGui.Styler

A powerful styling library for ImGui.NET interfaces featuring 50+ built-in themes (Catppuccin, Tokyo Night, Gruvbox, Dracula, Nord, and more), interactive theme browser, scoped styling system for colors and style variables, advanced color manipulation with hex support and accessibility features, automatic content alignment and centering, semantic text colors, button alignment, and indentation utilities.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.0.7 0 8/21/2026
3.0.6 54 8/20/2026
3.0.5 123 8/19/2026
3.0.4 158 8/19/2026
3.0.3 296 8/18/2026
3.0.2 112 8/17/2026
3.0.1 183 8/15/2026
3.0.0 119 8/15/2026
2.0.30 489 8/11/2026
2.0.29 259 8/11/2026
2.0.28 179 8/6/2026
2.0.27 132 8/5/2026
2.0.26 235 8/5/2026
2.0.25 128 8/4/2026
2.0.24 220 8/4/2026
2.0.23 243 7/31/2026
2.0.22 204 7/30/2026
2.0.21 215 7/29/2026
2.0.20 362 7/28/2026
2.0.19 205 7/27/2026
Loading failed

## v3.0.7 (patch)

Changes since v3.0.6:

- Bump the ktsu group with 10 updates ([@dependabot[bot]](https://github.com/dependabot[bot]))