SwiftUI macOS Toolbar Examples
There’s several ways to create a toolbar and a bunch of options for it also.
[…]
Adding a search field to the toolbar is easier than you think, simply add the
.searchable(text:)
modifier to a view within your content view.
There are options for the placement and prompt, but nothing on the documentation page tells how to use the search menu. I guess this is done using the separate searchScopes(_:scopes:) function, which seems limited compared to what NSSearchField offers. On the other hand, the SwiftUI version has support for suggestions, which I don’t think Apple ever added to AppKit except for its own apps.
Putting a segmented picker too close to the search field can result in it becoming trapped and unaccessible from the chevron menu when the search field is highlighted and then loses focus. I have filed this as a bug with Apple FB17392294.
Previously: