Contents

Modal presentations

Present content in a separate view that offers focused interaction.

Overview

To draw attention to an important, narrowly scoped task, you display a modal presentation, like an alert, popover, sheet, or confirmation dialog.

[Image]

In SwiftUI, you create a modal presentation using a view modifier that defines how the presentation looks and the condition under which SwiftUI presents it. SwiftUI detects when the condition changes and makes the presentation for you. Because you provide a Binding to the condition that initiates the presentation, SwiftUI can reset the underlying value when the user dismisses the presentation.

For design guidance, see Modality in the Human Interface Guidelines.

Topics

Configuring a dialog

Showing a sheet, cover, or popover

Adapting a presentation size

Configuring a sheet’s height

Styling a sheet and its background

Presenting an alert

Getting confirmation for an action

Showing a confirmation dialog with a message

Configuring a dialog

Exporting to file

Importing from file

Moving a file

Configuring a file dialog

Presenting an inspector

Dismissing a presentation

Deprecated modal presentations

See Also

App structure