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 8, 2024 How to make Squircle shape in SwiftUI and how to easily convert it to a circle or a rectangle?

To create a squircle shape (a combination of a square and a circle, also known as a superellipse) in SwiftUI, you can define a custom shape by conforming to the Shape protocol and implementing the superellipse formula. The formula for a superellipse is:

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 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.