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 macos September 3, 2024 Two ways to open a window programmatically in SwiftUI

SwiftUI provides an openWindow environment variable on macOS that allows you to open windows programmatically. Here’s how you can use it to open a new window when a button is clicked:

question swiftui macos September 3, 2024 How to open and close windows programmatically in SwiftUI?

To open or close a window programmatically from outside that window using environment variables, you need to leverage the new openWindow (macOS 13+) and dismissWindow (macOS 14+) environment variables. This environment variables allow you to programmatically open and close a window by its identifier.

question swiftui swift October 7, 2024 How to zoom in and zoom out a SwiftUI view?

In a macOS or iOS app, you can easily add a zoom feature to any SwiftUI view with the scaleEffect modifier. In the below example, I am using a Slider to control the zoom level. Here’s how you can implement zooming in and out with a slider:

Like my work?

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