maui-theming

Implements light and dark mode theming in .NET MAUI apps using AppThemeBinding and ResourceDictionary switching.

1|Updated Jun 1, 2026
One-click install
npx skills add https://github.com/D1ssolve/craft-agents --skill maui-theming-d1ssolve
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: maui-theming
Source: https://github.com/D1ssolve/craft-agents/tree/main/skills/maui-theming
Command: npx skills add https://github.com/D1ssolve/craft-agents --skill maui-theming-d1ssolve

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Adding light/dark mode and custom branded themes to a .NET MAUI app involves choosing between AppThemeBinding and ResourceDictionary swapping, wiring up system theme detection, and avoiding pitfalls like frozen StaticResource bindings or Android activity restarts. This Skill provides a structured workflow and tested code patterns to implement theme support correctly. ## Core Features & Use Cases - AppThemeBinding for OS-driven themes: Apply light/dark values in XAML or C# with SetAppThemeColor and SetAppTheme helpers. - ResourceDictionary theme switching: Define multiple custom themes as dictionaries with matching keys and swap them at runtime using DynamicResource bindings. - System detection and user preferences: Read RequestedTheme, override with UserAppTheme, react to RequestedThemeChanged, and persist choices with Preferences. - Use Case: A user wants their MAUI app to follow the OS dark mode setting while also offering an in-app theme picker. The Skill guides them to combine AppThemeBinding with dictionary swapping, persist the choice, and configure Android ConfigChanges.UiMode to avoid activity restarts. ## Quick Start Add light and dark mode support to my .NET MAUI app using AppThemeBinding and persist the user's theme preference.

Frequently Asked Questions about maui-theming

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add dark mode to a .NET MAUI app?

Use the AppThemeBinding markup extension to specify Light and Dark values for colors, such as TextColor="{AppThemeBinding Light=Green, Dark=Red}". In C#, use SetAppThemeColor or the generic SetAppTheme<T> extension method on any bindable property.

AppThemeBinding vs ResourceDictionary theming in .NET MAUI?

AppThemeBinding is best for automatic OS-driven light/dark switching with minimal code but supports only two themes. ResourceDictionary swapping supports custom branded themes and more than two themes, but requires DynamicResource bindings everywhere and more setup.

Why does my .NET MAUI app restart when the Android theme changes?

The MainActivity is missing ConfigChanges.UiMode in its ConfigurationChanges flags. Without it, toggling dark mode causes a full activity restart, losing navigation state. Add ConfigChanges.UiMode so the RequestedThemeChanged event fires instead.

Why doesn't my theme update when I switch ResourceDictionaries at runtime?

You are likely using StaticResource, which freezes values at first load. Use DynamicResource for all theme-bound properties so values update when the merged dictionary is swapped. Also verify every theme dictionary defines the same x:Key entries.

Can I swap CSS-based themes at runtime in .NET MAUI?

No. .NET MAUI supports CSS styling, but CSS-based themes cannot be swapped dynamically at runtime. For runtime theme switching, use ResourceDictionary theming with DynamicResource bindings instead.

How do I save the user's theme preference in .NET MAUI?

Store the choice with Preferences.Set("AppTheme", "Dark") and restore it on startup with Preferences.Get. Map the saved value to AppTheme.Light, AppTheme.Dark, or AppTheme.Unspecified and assign it to Application.Current.UserAppTheme.