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 August 31, 2024 @Published in SwiftUI

In SwiftUI, the @Published property wrapper is used in combination with the ObservableObject protocol to automatically announce changes to properties of a class. This allows SwiftUI views that depend on these properties to update automatically when the data changes.

question swiftui swift September 8, 2024 How to loop through an enum in SwiftUI?

In SwiftUI, looping through an enum is not directly possible without some extra work because enums in Swift don’t inherently support iteration. However, you can achieve this by making the enum CaseIterable, which automatically provides a collection of all cases in the enum.

question swiftui swift October 30, 2023 How to convert Color type to hex and vice-versa while retaining alpha information?

The below should work both on macOS and iOS with one minor change. That is, use UIColor instead of NSColor if you’re planning to use it for iOS.

Like my work?

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