Destructive actions and separators in SwiftUI Menu

Is there any way to add destructive actions (such as a delete button in red) or separators to the new Menu in iOS and iPadOS as shown in the Build/Design with iOS pickers, menus and actions talks?

There's no way that I know of with .contextMenu and I was wondering if there was a way or a workaround.



Answered by j-f1 in 630235022
Separators can be added by placing a Divider() in the menu. I don’t think destructive actions are available yet, unfortunately.
Accepted Answer
Separators can be added by placing a Divider() in the menu. I don’t think destructive actions are available yet, unfortunately.
Thanks j-f1.
I didn’t think of using a Divider().

It would be nice to have destructive actions but if it doesn’t come with the release Xcode 12 then I’ll have to find a way to use a UIMenu or place the delete button somewhere else.

Now on iOS 15.0+ you can initialize a button with the ButtonRole .destructive:

Button(role: .destructive, action: { print(""}) {
    Label("Delete", systemImage: "trash")
}
Destructive actions and separators in SwiftUI Menu
 
 
Q