uno-toolkit-system-theme-helper

Detect and switch system themes in Uno Platform apps with Uno.Toolkit.UI.

9|1|Updated Dec 10, 2024
One-click install
npx skills add https://github.com/unoplatform/studio --skill uno-toolkit-system-theme-helper
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: uno-toolkit-system-theme-helper
Source: https://github.com/unoplatform/studio/tree/main/plugins/uno-platform-studio/skills/uno-toolkit-system-theme-helper
Command: npx skills add https://github.com/unoplatform/studio --skill uno-toolkit-system-theme-helper

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

System theme detection and runtime switching can be cumbersome across platforms; this Skill provides a centralized API to detect the current OS theme and apply an app-level theme programmatically.

Core Features & Use Cases

  • GetCurrentOsTheme() returns Light or Dark.
  • GetRootTheme(XamlRoot?) and IsRootInDarkMode(XamlRoot?) determine theme state for a root.
  • SetRootTheme(XamlRoot?, bool) and SetApplicationTheme(XamlRoot?, ElementTheme) switch themes at runtime.
  • Use cases: Build theme-aware UI that responds to system theme; toggle dark mode in code; ensure cross-platform consistency.

Quick Start

Detect the current OS theme with GetCurrentOsTheme() and apply SetApplicationTheme(null, ElementTheme.Dark) to switch to dark mode.

Frequently Asked Questions about uno-toolkit-system-theme-helper

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

FAQPage Schema
How do I detect the system theme in an Uno Platform app?▼

You can detect the system theme by calling GetCurrentOsTheme(), which returns the current OS theme as Light or Dark for cross-platform Uno Platform projects.

How do I switch to dark mode at runtime in Uno Platform?▼

Switch to dark mode at runtime in Uno Platform by calling SetApplicationTheme(null, ElementTheme.Dark) or SetRootTheme(XamlRoot?, true) to apply the theme programmatically.

Does Uno Platform support cross-platform system theme detection?▼

Yes, Uno Platform supports cross-platform system theme detection across Windows, Web, iOS, and Android, enabling apps to detect and respond to OS theme changes consistently.

Can I check if the current XamlRoot is in dark mode?▼

Yes, you can check if the current XamlRoot is in dark mode by calling IsRootInDarkMode(XamlRoot?), which determines the theme state for a specific root element.

What is the best way to apply a theme programmatically in a cross-platform app?▼

The best way to apply a theme programmatically across Uno Platform targets is using SetRootTheme(XamlRoot?, bool) or SetApplicationTheme(XamlRoot?, ElementTheme) for safe runtime theme control.