Document title/proxy shifts left when adding an empty SwiftUI/AppKit toolbar - how to keep it centered?

I’m building a document-based macOS app using SwiftUI with an AppKit NSDocument.

By default, when the window has no toolbar, the document title and proxy icon (with the edited state dot and standard saving controls) appear nicely centered in the title bar.

However, as soon as I attach a toolbar - even an empty one - the document proxy moves to the leading edge of the title bar.

Is there a way to keep the document proxy/title centered in a document-based SwiftUI app while also using a toolbar? Or is the left-alignment now the only supported behavior when a toolbar is present?

Thanks in advance for any guidance.

For the 'unified' window style, where the window title is inline with the toolbar, the title always appears leading-aligned. This is the preferred style for windows with toolbars, but you can opt in to the .expanded toolbar style (seen in apps like Pages and Numbers) which puts the title above the toolbar and centers it on macOS Sequoia and earlier.

That said, starting in macOS Tahoe the window title is leading-aligned in all styles, so you should choose a toolbar style based on what's right for your toolbar, not based on how it'll align the title.

Document title/proxy shifts left when adding an empty SwiftUI/AppKit toolbar - how to keep it centered?
 
 
Q