Repository navigation
feat: Support for Accent color - #22851
Conversation
There was a problem hiding this comment.
Pull request overview
Adds OS accent color support to Uno’s theming pipeline by introducing a cross-platform accent palette helper and wiring it into resource dictionaries so ThemeResource accent keys can resolve dynamically at runtime.
Changes:
- Introduces
AccentColorHelper+AccentColorPalettewith platform implementations (WASM CSSAccentColor, Android 12+ dynamic color, Skia extensibility). - Injects accent colors into
SystemResources.xamltheme dictionaries viaAccentColorResourceUpdater, and switches key brush usages toThemeResourcefor dynamic updates. - Exposes a runtime override hook via
FeatureConfiguration.AccentColor.OverrideAccentColorand integrates change notifications intoApplication/UISettings.
Reviewed changes
Copilot reviewed 17 out of 18 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Uno.UWP/ts/Windows/Helpers/Theming/AccentColorHelper.ts | WASM-side JS helper to read CSS AccentColor and observe changes (best-effort via media query). |
| src/Uno.UWP/js/Uno.Wasm.d.ts | Adds TS declaration for Uno.Helpers.Theming.AccentColorHelper. |
| src/Uno.UWP/UI/ViewManagement/UISettings.cs | Routes UIColorType.Accent* to the new AccentColorHelper palette instead of hardcoded constants. |
| src/Uno.UWP/Helpers/Theming/IAccentColorExtension.skia.cs | Defines Skia extensibility contract for OS accent palette + change notifications. |
| src/Uno.UWP/Helpers/Theming/AccentColorPalette.cs | Adds a 7-color accent palette model + default palette + derivation from a single accent color. |
| src/Uno.UWP/Helpers/Theming/AccentColorHelper.wasm.cs | WASM platform implementation to retrieve/observe accent via JSImport + JS helper. |
| src/Uno.UWP/Helpers/Theming/AccentColorHelper.skia.cs | Skia implementation using ApiExtensibility and IAccentColorExtension. |
| src/Uno.UWP/Helpers/Theming/AccentColorHelper.others.cs | Stubbed platform implementation for unit tests / reference builds. |
| src/Uno.UWP/Helpers/Theming/AccentColorHelper.cs | Core helper: caching, override support, refresh + change event plumbing. |
| src/Uno.UWP/Helpers/Theming/AccentColorHelper.UIKit.cs | UIKit stub returning no OS accent palette. |
| src/Uno.UWP/Helpers/Theming/AccentColorHelper.Interop.wasm.cs | JSImport declarations for calling into the WASM JS helper. |
| src/Uno.UWP/Helpers/Theming/AccentColorHelper.Android.cs | Android 12+ accent retrieval via system dynamic color resources. |
| src/Uno.UI/UI/Xaml/Style/Generic/SystemResources.xaml | Switches several accent usages to ThemeResource so accent updates can flow dynamically. |
| src/Uno.UI/UI/Xaml/Application.cs | Subscribes to accent changes and triggers resource + UISettings updates. |
| src/Uno.UI/UI/Xaml/AccentColorResourceUpdater.cs | New helper that injects current accent palette values into system theme dictionaries. |
| src/Uno.UI/FeatureConfiguration.cs | Adds FeatureConfiguration.AccentColor.OverrideAccentColor to override the accent at runtime. |
| src/Uno.UI.Runtime.Skia.Win32/Hosting/Win32Host.cs | Registers the Win32 Skia IAccentColorExtension implementation. |
| src/Uno.UI.Runtime.Skia.Win32/Helpers/Theming/Win32AccentColorExtension.cs | Win32 implementation reading AccentPalette from registry + watching for registry changes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-22851/wasm-skia-net9/index.html |
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-22851/wasm-skia-net9/index.html |
|
The build 202349 found UI Test snapshots differences: Details
|
|
|
There was a problem hiding this comment.
Pull request overview
This PR adds dynamic system accent color support across Uno by introducing an accent palette abstraction, wiring it into UISettings.GetColorValue(UIColorType.Accent*), and updating system resources to resolve accent-related keys via ThemeResource so they can be updated at runtime (with platform implementations for Android and Skia hosts).
Changes:
- Route
UISettingsaccent color queries through a newAccentColorHelper+AccentColorPaletteinstead of hardcoded values. - Add runtime updating of
SystemAccentColor*(and related resources/brushes) viaAccentColorResourceUpdater, triggered fromApplicationon accent changes. - Introduce platform accent retrieval hooks (Android 12+ Material You, Skia Win32 registry palette, Skia macOS native callback) and a
FeatureConfiguration.AccentColor.OverrideAccentColoroverride for deterministic behavior.
Reviewed changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Uno.UWP/UI/ViewManagement/UISettings.cs | Switches accent UIColorType values to use AccentColorHelper.CurrentPalette. |
| src/Uno.UWP/Helpers/Theming/AccentColorPalette.cs | Defines a 7-color accent palette and derives shades from a single accent color. |
| src/Uno.UWP/Helpers/Theming/AccentColorHelper.cs | Central helper for palette resolution (override/platform/default) and change notifications. |
| src/Uno.UWP/Helpers/Theming/AccentColorHelper.Android.cs | Retrieves Android 12+ system accent and derives palette. |
| src/Uno.UWP/Helpers/Theming/AccentColorHelper.skia.cs | Skia extension hook for palette retrieval + change notification. |
| src/Uno.UWP/Helpers/Theming/IAccentColorExtension.skia.cs | New Skia extension contract for accent palette + change events. |
| src/Uno.UWP/Helpers/Theming/AccentColorHelper.UIKit.cs / .wasm.cs / .others.cs | Platform stubs returning null when unsupported. |
| src/Uno.UI/UI/Xaml/Style/Generic/SystemResources.xaml | Converts several accent brush color bindings from StaticResource to ThemeResource. |
| src/Uno.UI/UI/Xaml/Application.cs | Subscribes to accent changes, updates resources, and refreshes accent on theme changes. |
| src/Uno.UI/UI/Xaml/AccentColorResourceUpdater.cs | Injects updated accent keys/brushes into the system dictionaries at runtime. |
| src/Uno.UI/FeatureConfiguration.cs | Adds FeatureConfiguration.AccentColor.OverrideAccentColor to override system accent. |
| src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Documents/Given_Hyperlink.cs | Uses an accent override helper for deterministic hyperlink tests. |
| src/Uno.UI.Runtime.Skia.Win32/Hosting/Win32Host.cs | Registers the Win32 accent extension with ApiExtensibility. |
| src/Uno.UI.Runtime.Skia.Win32/Helpers/Theming/Win32AccentColorExtension.cs | Reads Windows accent palette from registry + watches for changes. |
| src/Uno.UI.Runtime.Skia.MacOS/UnoNativeMac/UnoNativeMac/UNOApplication.m / .h | Adds native callback + getter for macOS control accent color and change notifications. |
| src/Uno.UI.Runtime.Skia.MacOS/Native/NativeUno.cs | Adds P/Invoke declarations for macOS accent APIs. |
| src/Uno.UI.Runtime.Skia.MacOS/Hosting/MacSkiaHost.cs | Registers the macOS accent extension. |
| src/Uno.UI.Runtime.Skia.MacOS/Helpers/Theming/MacOSAccentColorExtension.cs | Implements Skia macOS accent palette retrieval + change event bridging. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-22851/wasm-skia-net9/index.html |
1 similar comment
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-22851/wasm-skia-net9/index.html |
|
The build 202735 found UI Test snapshots differences: Details
|
|
|
f35759b to
1dccbec
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 21 out of 21 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-22851/wasm-skia-net9/index.html |
|
The build 204506 found UI Test snapshots differences: Details
|
|
|
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-22851/wasm-skia-net9/index.html |
Drop AccentColorResourceUpdater. The accent entries of FrameworkTheming's color and brush list now reach the system resources from NotifyThemeChange, like MUX's UpdateColorAndBrushResources, and accent changes go through FrameworkTheming.OnThemeChanged as JupiterWindow's ColorValuesChanged handler does. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TXMNtyrxcH4SsHeU1KRcFo
Track the 1:1 FrameworkTheming, Theme and ThemingInterop ports at WinUI 2.7.0. The upstream files are unchanged between the ports' header commit fc2f82117 and the tag, and a line-by-line review found no unmarked gaps. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TXMNtyrxcH4SsHeU1KRcFo
6f3d929 to
4a9bb52
Compare
|
Claude finished @MartinZikmund's task in 31s —— View job Review of the latest commits (
|
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TXMNtyrxcH4SsHeU1KRcFo
|
This pull request is merged. |
Shades are now derived with the Windows algorithm; document NormalizeAccentColor for reproducing the Windows accent adjustment. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_017LK9RwksucipQ9WtcSZ7xQ
|
Claude finished @MartinZikmund's task in 28s —— View job Review of the latest commit (
|
|
The build 248191 found UI Test snapshots differences: Details
|
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TXMNtyrxcH4SsHeU1KRcFo
|
Claude finished @MartinZikmund's task in 29s —— View job Review of the Linux/X11 accent extension and docs commitsVerdict: no blockers, one low-severity finding. Review was by code inspection only. I did not build or run anything. The checkout is shallow with no merge base against Issues by severity: 0 high, 0 medium, 1 low (posted inline). What looks right in
Cross-cutting notes
|
|
🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-22851/docs/index.html |
|
🤖 Your WebAssembly Sample App stage site is ready! Visit it here: |
|
The build 248202 found UI Test snapshots differences: Details
|
Drop an initial accent read that reaches the UI thread after a SettingChanged value, and own the DBus connection, disposing it on the early-exit paths. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TXMNtzaC5dx4oo2ZVG5BHB
|
Claude finished @MartinZikmund's task in 22s —— View job Review of the latest commit (
|
|
🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-22851/docs/index.html |
|
🤖 Your WebAssembly Sample App stage site is ready! Visit it here: |
|
The build 248269 found UI Test snapshots differences: Details
|
GitHub Issue: closes #4444
PR Type:
✨ Feature
What changed? 🚀
Uno Platform used a hardcoded blue for all accent resources, regardless of the OS accent color. This PR makes the accent follow the operating system, like WinUI.
OS accent sources
Resources, aligned with WinUI's
FrameworkTheming::RebuildColorAndBrushResourcesSystemAccentColor,SystemAccentColorLight1-3/Dark1-3,SystemColorControlAccentColorandSystemColorControlAccentBrushfollow the palette, as doSystemListAccentLow/Medium/HighColor(the accent with alpha0x66/0x99/0xB2).SystemColorHighlightColoris not touched: WinUI sources it from the system highlight color, independently of the accent.UISettings.GetColorValue(UIColorType.Accent*)returns the same palette, andColorValuesChangedfires when it changes.{ThemeResource}references update live; as in WinUI,{StaticResource}references keep their resolved value.Shades derived like Windows 11
When a platform exposes only one accent color, the six shades are derived with the same algorithm Windows 11 uses. It was validated against palettes captured from Windows (
UISettings.GetColorValue) for 1,326 accent colors, 9,282 of 9,282 shades matching. It was also checked against the resources a blank WinUI 3 app resolves on 191 accents. The unit tests use captured Windows values as expectations.New
FeatureConfiguration.AccentColoroptionsOverrideAccentColor: forces an app accent. Set it tonullto follow the OS again.NormalizeAccentColor(defaultfalse): Windows adjusts the lightness of a color picked in its Settings before deriving shades. By default, Uno Platform keeps the provided accent exactly. Set this totrueto reproduce the Windows adjustment.Tests
Given_AccentColorPalette(captured Windows palettes, swatch colors, normalization, ordered shades).Given_UISettings_Accent(override updatesGetColorValueand resources, highlight independence, normalization toggle).Given_Hyperlink: the tests pin the default palette, mirroring WinUI's test accent override, which returns fixed shades.SystemAccentColorSample.Stacked on top: #24424 (Linux/X11 accent) and #24428 (docs).
PR Checklist ✅
Screenshots Compare Test Runresults.🤖 Generated with Claude Code
https://claude.ai/code/session_017LK9RwksucipQ9WtcSZ7xQ