[Feature]support WindowSetSystemDefaultTheme,WindowSetLightTheme,WindowSetDarkTheme for darwin(#4654)
Description
Support functions: WindowSetSystemDefaultTheme,WindowSetLightTheme,WindowSetDarkTheme for darwin(basing on v2.10.2) and update documents. And it test OK in my device.
Feature #4654 (issue)
Type of change
Please select the option that is relevant.
- [ ] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [x] This change requires a documentation update
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration using wails doctor.
- [ ] Windows
- [x] macOS
- [ ] Linux
If you checked Linux, please specify the distro and version.
Test Configuration
wails on feature/4654-runtime-SetAppearance-for-darwin
❯ wails doctor
Wails Doctor
# Wails
Version | v2.10.2
# System
┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
| OS | MacOS |
| Version | 15.6.1 |
| ID | 24G90 |
| Branding | |
| Go Version | go1.24.4 |
| Platform | darwin |
| Architecture | arm64 |
| CPU 1 | Apple M1 |
| CPU 2 | Apple M1 |
| GPU | Chipset Model: Apple M1 Type: GPU Bus: Built-In Total Number of Cores: 8 Vendor: Apple (0x106b) Metal Support: Metal 3 |
| Memory | 16GB |
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
# Dependencies
┌────────────────────────────────────────────────────────────────────────┐
| Dependency | Package Name | Status | Version |
| Xcode command line tools | N/A | Installed | 2410 |
| Nodejs | N/A | Installed | 24.3.0 |
| npm | N/A | Installed | 11.4.2 |
| *Xcode | N/A | Installed | 26.0.1 (17A400) |
| *upx | N/A | Available | |
| *nsis | N/A | Available | |
| |
└─────────────────────── * - Optional Dependency ────────────────────────┘
# Diagnosis
Optional package(s) installation details:
- upx : Available at https://upx.github.io/
- nsis : More info at https://wails.io/docs/guides/windows-installer/
SUCCESS Your system is ready for Wails development!
♥ If Wails is useful to you or your company, please consider sponsoring the project:
https://github.com/sponsors/leaanthony
GO Unit Test:
wails/v2 on feature/4654-runtime-SetAppearance-for-darwin via 🐹 v1.25.1
❯ go test ./...
? github.com/wailsapp/wails/v2 [no test files]
? github.com/wailsapp/wails/v2/cmd/wails [no test files]
? github.com/wailsapp/wails/v2/cmd/wails/flags [no test files]
? github.com/wailsapp/wails/v2/cmd/wails/internal [no test files]
# github.com/wailsapp/wails/v2/internal/frontend/desktop/darwin
WailsContext.m:164:18: warning: 'setShowsBaselineSeparator:' is deprecated: first deprecated in macOS 15.0 - No longer supported [-Wdeprecated-declarations]
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSToolbar.h:299:16: note: property 'showsBaselineSeparator' is declared deprecated here
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSToolbar.h:299:16: note: 'setShowsBaselineSeparator:' has been explicitly marked deprecated here
ok github.com/wailsapp/wails/v2/cmd/wails/internal/dev 0.488s
? github.com/wailsapp/wails/v2/cmd/wails/internal/gomod [no test files]
? github.com/wailsapp/wails/v2/cmd/wails/internal/logutils [no test files]
? github.com/wailsapp/wails/v2/cmd/wails/internal/template [no test files]
? github.com/wailsapp/wails/v2/cmd/wails/internal/template/base [no test files]
? github.com/wailsapp/wails/v2/internal/app [no test files]
ok github.com/wailsapp/wails/v2/internal/binding 0.648s
ok github.com/wailsapp/wails/v2/internal/binding/binding_test 1.196s
? github.com/wailsapp/wails/v2/internal/binding/binding_test/binding_test_import [no test files]
? github.com/wailsapp/wails/v2/internal/binding/binding_test/binding_test_import/binding_test_nestedimport [no test files]
? github.com/wailsapp/wails/v2/internal/binding/binding_test/binding_test_import/float_package [no test files]
? github.com/wailsapp/wails/v2/internal/binding/binding_test/binding_test_import/int_package [no test files]
? github.com/wailsapp/wails/v2/internal/binding/binding_test/binding_test_import/map_package [no test files]
? github.com/wailsapp/wails/v2/internal/binding/binding_test/binding_test_import/uint_package [no test files]
? github.com/wailsapp/wails/v2/internal/colour [no test files]
? github.com/wailsapp/wails/v2/internal/frontend [no test files]
? github.com/wailsapp/wails/v2/internal/frontend/desktop [no test files]
? github.com/wailsapp/wails/v2/internal/frontend/desktop/darwin [no test files]
? github.com/wailsapp/wails/v2/internal/frontend/dispatcher [no test files]
ok github.com/wailsapp/wails/v2/internal/frontend/runtime 1.363s
? github.com/wailsapp/wails/v2/internal/frontend/runtime/wrapper [no test files]
ok github.com/wailsapp/wails/v2/internal/fs 1.829s
ok github.com/wailsapp/wails/v2/internal/github 2.043s
? github.com/wailsapp/wails/v2/internal/go-common-file-dialog/cfd [no test files]
? github.com/wailsapp/wails/v2/internal/go-common-file-dialog/cfdutil [no test files]
ok github.com/wailsapp/wails/v2/internal/go-common-file-dialog/util2.430s
ok github.com/wailsapp/wails/v2/internal/gomod 2.829s
? github.com/wailsapp/wails/v2/internal/goversion [no test files]
? github.com/wailsapp/wails/v2/internal/logger [no test files]
? github.com/wailsapp/wails/v2/internal/menumanager [no test files]
? github.com/wailsapp/wails/v2/internal/process [no test files]
ok github.com/wailsapp/wails/v2/internal/project 3.181s
? github.com/wailsapp/wails/v2/internal/s [no test files]
ok github.com/wailsapp/wails/v2/internal/shell 2.712s
? github.com/wailsapp/wails/v2/internal/signal [no test files]
ok github.com/wailsapp/wails/v2/internal/staticanalysis 6.001s
? github.com/wailsapp/wails/v2/internal/system [no test files]
? github.com/wailsapp/wails/v2/internal/system/operatingsystem [no test files]
? github.com/wailsapp/wails/v2/internal/system/packagemanager [no test files]
? github.com/wailsapp/wails/v2/internal/typescriptify [no test files]
? github.com/wailsapp/wails/v2/internal/webview2runtime [no test files]
? github.com/wailsapp/wails/v2/pkg/application [no test files]
ok github.com/wailsapp/wails/v2/pkg/assetserver 2.854s
? github.com/wailsapp/wails/v2/pkg/assetserver/webview [no test files]
? github.com/wailsapp/wails/v2/pkg/buildassets [no test files]
? github.com/wailsapp/wails/v2/pkg/clilogger [no test files]
ok github.com/wailsapp/wails/v2/pkg/commands/bindings 8.103s
ok github.com/wailsapp/wails/v2/pkg/commands/build 3.204s
ok github.com/wailsapp/wails/v2/pkg/commands/buildtags 3.242s
ok github.com/wailsapp/wails/v2/pkg/git 2.973s
? github.com/wailsapp/wails/v2/pkg/logger [no test files]
ok github.com/wailsapp/wails/v2/pkg/mac 3.653s
ok github.com/wailsapp/wails/v2/pkg/menu 2.886s
? github.com/wailsapp/wails/v2/pkg/menu/colours [no test files]
ok github.com/wailsapp/wails/v2/pkg/menu/keys 2.477s
ok github.com/wailsapp/wails/v2/pkg/options 2.129s
? github.com/wailsapp/wails/v2/pkg/options/assetserver [no test files]
? github.com/wailsapp/wails/v2/pkg/options/linux [no test files]
? github.com/wailsapp/wails/v2/pkg/options/mac [no test files]
? github.com/wailsapp/wails/v2/pkg/options/windows [no test files]
? github.com/wailsapp/wails/v2/pkg/runtime [no test files]
ok github.com/wailsapp/wails/v2/pkg/templates 2.613s
? github.com/wailsapp/wails/v2/pkg/templates/base [no test files]
? github.com/wailsapp/wails/v2/pkg/templates/generate [no test files]
? github.com/wailsapp/wails/v2/pkg/templates/generate/plain [no test files]
? github.com/wailsapp/wails/v2/pkg/templates/templates/lit [no test files]
? github.com/wailsapp/wails/v2/pkg/templates/templates/lit-ts [no test files]
? github.com/wailsapp/wails/v2/pkg/templates/templates/plain [no test files]
? github.com/wailsapp/wails/v2/pkg/templates/templates/preact [no test files]
? github.com/wailsapp/wails/v2/pkg/templates/templates/preact-ts [no test files]
? github.com/wailsapp/wails/v2/pkg/templates/templates/react [no test files]
? github.com/wailsapp/wails/v2/pkg/templates/templates/react-ts [no test files]
? github.com/wailsapp/wails/v2/pkg/templates/templates/svelte [no test files]
? github.com/wailsapp/wails/v2/pkg/templates/templates/svelte-ts [no test files]
? github.com/wailsapp/wails/v2/pkg/templates/templates/vanilla [no test files]
? github.com/wailsapp/wails/v2/pkg/templates/templates/vanilla-ts [no test files]
? github.com/wailsapp/wails/v2/pkg/templates/templates/vue [no test files]
? github.com/wailsapp/wails/v2/pkg/templates/templates/vue-ts [no test files]
? github.com/wailsapp/wails/v2/tools/release [no test files]
Checklist:
- [ ] I have updated
website/src/pages/changelog.mdxwith details of this PR - [x] My code follows the general coding style of this project
- [x] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [x] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my feature works
- [x] New and existing unit tests pass locally with my changes
Summary by CodeRabbit
-
New Features
- macOS: Window appearance control added — set Light, Dark or System Default themes.
-
Bug Fixes
- Appearance changes now apply reliably on macOS windows.
-
Documentation
- Theme method docs clarified: Linux unsupported; macOS supported for window theming.
✏️ Tip: You can customize this high-level summary in your review settings.
Walkthrough
Adds macOS appearance support: new SetAppearance layers implemented in Objective-C (C bridge + WailsContext) and exposed to Go frontend; Window theme functions now call into the new appearance setter. Documentation updated to mark Linux unsupported for those theming methods.
Changes
| Cohort / File(s) | Summary |
|---|---|
Objective-C C bridge layer v2/internal/frontend/desktop/darwin/Application.h, v2/internal/frontend/desktop/darwin/Application.m |
Added SetAppearance(void* ctx, const char* appearance) C function bridging to WailsContext and dispatching the call on the main thread. |
WailsContext interface & implementation v2/internal/frontend/desktop/darwin/WailsContext.h, v2/internal/frontend/desktop/darwin/WailsContext.m |
Added - (void) SetAppearance:(NSString*)appearance; which resolves an NSAppearance by name and applies it to the main window when available. |
Go frontend bindings v2/internal/frontend/desktop/darwin/frontend.go, v2/internal/frontend/desktop/darwin/window.go |
Imported mac appearance names and added (*Window) SetAppearance(appearance string); WindowSetSystemDefaultTheme / WindowSetLightTheme / WindowSetDarkTheme now call the new setter. |
Documentation website/docs/reference/runtime/window.mdx |
Updated theming method docs from “Windows only.” to “Linux is unsupported.” |
Sequence Diagram
sequenceDiagram
participant App as App code (Go runtime)
participant Win as Window (darwin/window.go)
participant CBridge as C bridge (Application.m)
participant WailsCtx as WailsContext
participant macOS as AppKit (NSWindow)
App->>Win: call SetAppearance("Aqua"/"DarkAqua"/default)
Win->>CBridge: SetAppearance(ctx, cString)
CBridge->>CBridge: dispatch_async(main thread)
CBridge->>WailsCtx: [ctx SetAppearance:NSString]
WailsCtx->>WailsCtx: resolve NSAppearance by name
WailsCtx->>macOS: window.appearance = resolvedAppearance
macOS-->>WailsCtx: applied
WailsCtx-->>CBridge: return
CBridge-->>Win: return
Win->>Win: free C resources
Estimated code review effort
🎯 3 (Moderate) | ⏱️ ~20 minutes
- Pay attention to main-thread dispatch in
Application.mand safety ofsafeInit/string conversions. - Verify NSAppearance name mapping and behavior when appearance is nil or unrecognized.
- Confirm Go-to-C memory allocation/deallocation in
window.gois correct.
Suggested labels
Enhancement, Documentation, MacOS
Suggested reviewers
- leaanthony
Poem
🐰 With twitching nose I hop and cheer,
I paint the Mac with light and sheer.
From dark to aqua, themes take flight—
I set the look, then off I bite! ✨
Pre-merge checks and finishing touches
✅ Passed checks (3 passed)
| Check name | Status | Explanation |
|---|---|---|
| Title check | ✅ Passed | The title clearly describes the main feature: adding support for three window theming functions (WindowSetSystemDefaultTheme, WindowSetLightTheme, WindowSetDarkTheme) for macOS, with explicit issue reference (#4654). |
| Description check | ✅ Passed | The description covers key sections: summary of changes, feature type selection, testing confirmation on macOS with system details (wails doctor output), unit test results, and most checklist items completed. Documentation updates are confirmed as done. |
| Docstring Coverage | ✅ Passed | No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. |
✨ Finishing touches
- [ ] 📝 Generate docstrings
🧪 Generate unit tests (beta)
- [ ] Create PR with unit tests
- [ ] Post copyable unit tests in a comment
[!TIP]
📝 Customizable high-level summaries are now available in beta!
You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.
- Provide your own instructions using the
high_level_summary_instructionssetting.- Format the summary however you like (bullet lists, tables, multi-section layouts, contributor stats, etc.).
- Use
high_level_summary_in_walkthroughto move the summary from the description to the walkthrough section.Example instruction:
"Divide the high-level summary into five sections:
- 📝 Description — Summarize the main change in 50–60 words, explaining what was done.
- 📓 References — List relevant issues, discussions, documentation, or related PRs.
- 📦 Dependencies & Requirements — Mention any new/updated dependencies, environment variable changes, or configuration updates.
- 📊 Contributor Summary — Include a Markdown table showing contributions:
| Contributor | Lines Added | Lines Removed | Files Changed |- ✔️ Additional Notes — Add any extra reviewer context. Keep each section concise (under 200 words) and use bullet or numbered lists for clarity."
Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands and usage tips.
Quality Gate passed
Issues
0 New issues
0 Accepted issues
Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code
I will get to this. Thanks for your patience 🙏
Quality Gate passed
Issues
0 New issues
0 Accepted issues
Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code