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)
}
Presentify

Take your presentation to the next level.

FaceScreen

Put your face and name on your screen.

KeyScreen

Show keypresses on your screen.

ToDoBar

Your to-dos on your menu bar.

SimpleFill

Fill forms using your right-click menu.

IconSim

Preview your Mac app icons.

Ram Patra Published on June 7, 2025
Image placeholder

Keep reading

If this article was helpful, others might be too

question swiftui iOS April 2, 2024 How to open a second view from first view in iOS using SwiftUI?

In SwiftUI, you can open another view (or navigate to another view) on the click of a button by utilizing navigation views and navigation links. Here’s a basic example of how to achieve this:

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 March 6, 2023 How to render the icon on a menu bar as a template in SwiftUI?

Setting your app’s icon on the menu bar as a template makes it to adapt to light and dark modes automatically without you doing anything. To do this, you have to use this constructor of MenuBarExtra class.

Like my work?

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