Emulate AppKit NSPopUpButton in SwiftUI

How to make a control that looks and feels as close as possible to NSPopUpButton in SwiftUI, so a Mac user accepts the control as being native Mac UI?

Items should have icon and text, I need separators between some items and certain items may be disabled at times, so they should not be selectable.

Picker seems to lack some of those features (separators and disabled items), and Menu looks and behaves differently. Any guidance?

For now I went with Menu, but find both the "chevron.down" icon at the trailing end as well as the positioning of the menu below the control weird.

The Pop-up button page in the HIG has a link to SwiftUI MenuPickerStyle along with a link to NSPopUpButton for AppKit.

I'm actually not familiar with AppKit or SwiftUI (just UIKit) but hopefully that points you in the right direction.

Picker seems to lack some of those features (separators and disabled items), and Menu looks and behaves differently. Any guidance?

Using a Picker with the pickerStyle(.menu) is the way to go to go. Populating SwiftUI menus with adaptive controls is a good resource to learn about menu and pickers.

You can also bring your NSPopUpButton implementation to SwiftUI using NSHostingView

Emulate AppKit NSPopUpButton in SwiftUI
 
 
Q