Delete Confirmation Dialog Inside Toolbar IOS26

inline-code

How do you achieve this effect in toolbar? Where is the documentation for this?

  • How to make it appear top toolbar or bottom toolbar?

Thank you!

Here is what I have now...

 .toolbar {
                             ToolbarItem(placement: .destructiveAction) {
                                 Button {
                                     showConfirm = true
                                 } label: {
                                     Image(systemName: "trash")
                                         .foregroundColor(.red)
                                 }
                             }
                         }
                         .confirmationDialog(
                             "Are you sure?",
                             isPresented: $showConfirm,
                             titleVisibility: .visible
                         ) {
                             Button("Delete Item", role: .destructive) {
                                 print("Deleted")
                             }

                             Button("Archive", role: .none) {
                                 print("Archived")
                             }

                             Button("Cancel", role: .cancel) { }
                         }
}
Answered by extraman in 875147022

Figured out the implementation! For anyone interested in implementing in IOS 26+

 @Namespace private var namespace
@State private var presentDialog: Bool = false

and in the toolbar

     ToolbarItem(placement: .cancellationAction){
                    Button(role: .destructive) {
                        presentDialog = true
                    } label: {
                        Text("Delete")
                    }
                    .confirmationDialog(
                        "Delete?",
                        isPresented: $presentDialog,
                        titleVisibility: .visible
                    ) {
                        Button("Delete", role: .destructive) {
                            // perform delete
                        }
                        Button("Cancel", role: .cancel) { }
                    }
                }
Accepted Answer

Figured out the implementation! For anyone interested in implementing in IOS 26+

 @Namespace private var namespace
@State private var presentDialog: Bool = false

and in the toolbar

     ToolbarItem(placement: .cancellationAction){
                    Button(role: .destructive) {
                        presentDialog = true
                    } label: {
                        Text("Delete")
                    }
                    .confirmationDialog(
                        "Delete?",
                        isPresented: $presentDialog,
                        titleVisibility: .visible
                    ) {
                        Button("Delete", role: .destructive) {
                            // perform delete
                        }
                        Button("Cancel", role: .cancel) { }
                    }
                }
Delete Confirmation Dialog Inside Toolbar IOS26
 
 
Q