Loading...

How to change the accent colour of a macOS app in SwiftUI?

question swiftui macos
Ram Patra Published on June 7, 2025

To change the accent color of a SwiftUI macOS app, you can do it in any of the following ways:

1. Set Global Accent Color in the .xcassets (I prefer this personally)

  1. Open Assets.xcassets
  2. Click +New Color Set
  3. Name it AccentColor
  4. Set its Appearances to None (or configure Light/Dark if needed)
  5. Choose a color (e.g., orange)
  6. Ensure your Info.plist has the key AccentColorName pointing to AccentColor (usually done automatically but sometimes you will have to manually add it)

This will apply app-wide unless overridden locally.

2. Set .accentColor in your SwiftUI view

This will apply to the specific view hierarchy:

@main
struct MyApp: App {
    var body: some Scene {
        WindowGroup {
            ContentView()
                .accentColor(.orange) // Change to your desired color
        }
    }
}

3. Use tint(_:) in SwiftUI 3+ (macOS 12+)

For more recent APIs, Apple recommends using .tint(_:):

ContentView()
    .tint(.orange)

Manually modify Info.plist

Ensure your Info.plist has:

<key>NSAccentColorName</key>
<string>AccentColor</string>

Bonus: Dynamically change accent color

If you want to let users choose or switch themes dynamically:

@AppStorage("accentColorName") var accentColorName: String = "blue"

var accentColor: Color {
    switch accentColorName {
    case "orange": return .orange
    case "green": return .green
    default: return .blue
    }
}

var body: some View {
    ContentView()
        .tint(accentColor)
}

Take your presentation to the next level.

Put your face and name on your screen.

Your to-dos on your menu bar.

Fill forms using your right-click menu.

Ram Patra Published on June 7, 2025
Image placeholder

Keep reading

If this article was helpful, others might be too

question swiftui swift September 30, 2023 How to open the Settings view in a SwiftUI app on macOS 14.0 (Sonoma)?

In macOS 14.0 (Sonoma), Apple removed support for NSApp.sendAction to open the Settings view in your SwiftUI app. You now have to use SettingsLink like below:

question swiftui swift February 19, 2025 How to change the window level to floating, popUpMenu, etc. in SwiftUI?

When developing macOS applications with SwiftUI, you might need to create floating windows that stay on top of other windows. While modern macOS versions (15+) make this straightforward with the .windowLevel(.floating) modifier, supporting older versions requires a different approach. In this post, I’ll show you how to create floating windows that work across different macOS versions.

question swiftui April 2, 2024 How to declare an array of Views in SwiftUI?

In SwiftUI, you can declare an array of View using the standard Swift array syntax. Here’s how you can do it:

Like my work?

Please, feel free to reach out. I would be more than happy to chat.