DismissBehavior

Programmatic window dismissal behaviors.

StructureiOS 17.0+macOS 14.0+DismissBehavior in SwiftUI

Declaration

React
type DismissBehavior = 'destructive' | 'interactive';
Swift
struct DismissBehavior

Pass a literal, or build one with SwiftUI.DismissBehavior from import { SwiftUI } from 'swiftui-react-native'.

Type properties

Overview

Use values of this type to control window dismissal during the current transaction.

For example, to dismiss windows showing a modal presentation that would otherwise prohibit dismissal, use the destructive behavior:

struct DismissWindowButton: View {
    @Environment(\.dismissWindow) private var dismissWindow

    var body: some View {
        Button("Close Auxiliary Window") {
            withTransaction(\.dismissBehavior, .destructive) {
                dismissWindow(id: "auxiliary")
            }
        }
    }
}

From Apple’s SwiftUI documentation. Code samples there are Swift.

Used by

See also

More in Presentation.