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
sheet(isPresented:onDismiss:content:)sheet(item:onDismiss:content:)fullScreenCover(isPresented:onDismiss:content:)fullScreenCover(item:onDismiss:content:)popover(item:attachmentAnchor:arrowEdge:content:)popover(isPresented:attachmentAnchor:arrowEdge:content:)PopoverAttachmentAnchor
Adapting a presentation size
presentationCompactAdaptation(horizontal:vertical:)presentationCompactAdaptation(_:)PresentationAdaptationpresentationSizing(_:)PresentationSizingPresentationSizingRootPresentationSizingContext
Configuring a sheet’s height
presentationDetents(_:)presentationDetents(_:selection:)presentationContentInteraction(_:)presentationDragIndicator(_:)PresentationDetentCustomPresentationDetentPresentationContentInteraction
Styling a sheet and its background
presentationCornerRadius(_:)presentationBackground(_:)presentationBackground(alignment:content:)presentationBackgroundInteraction(_:)PresentationBackgroundInteraction
Presenting an alert
AlertScenealert(_:isPresented:actions:)alert(_:isPresented:presenting:actions:)alert(isPresented:error:actions:)alert(_:isPresented:actions:message:)alert(_:isPresented:presenting:actions:message:)alert(isPresented:error:actions:message:)
Getting confirmation for an action
confirmationDialog(_:isPresented:titleVisibility:actions:)confirmationDialog(_:isPresented:titleVisibility:presenting:actions:)dismissalConfirmationDialog(_:shouldPresent:actions:)
Showing a confirmation dialog with a message
confirmationDialog(_:isPresented:titleVisibility:actions:message:)confirmationDialog(_:isPresented:titleVisibility:presenting:actions:message:)dismissalConfirmationDialog(_:shouldPresent:actions:message:)
Configuring a dialog
dialogIcon(_:)dialogIcon(_:)dialogSeverity(_:)dialogSeverity(_:)dialogSuppressionToggle(isSuppressed:)dialogSuppressionToggle(isSuppressed:)dialogSuppressionToggle(_:isSuppressed:)dialogSuppressionToggle(_:isSuppressed:)
Exporting to file
fileExporter(isPresented:document:contentType:defaultFilename:onCompletion:)fileExporter(isPresented:documents:contentType:onCompletion:)fileExporter(isPresented:document:contentTypes:defaultFilename:onCompletion:onCancellation:)fileExporter(isPresented:documents:contentTypes:onCompletion:onCancellation:)fileExporter(isPresented:item:contentTypes:defaultFilename:onCompletion:onCancellation:)fileExporter(isPresented:items:contentTypes:onCompletion:onCancellation:)fileExporterFilenameLabel(_:)
Importing from file
fileImporter(isPresented:allowedContentTypes:allowsMultipleSelection:onCompletion:)fileImporter(isPresented:allowedContentTypes:onCompletion:)fileImporter(isPresented:allowedContentTypes:allowsMultipleSelection:onCompletion:onCancellation:)
Moving a file
fileMover(isPresented:file:onCompletion:)fileMover(isPresented:files:onCompletion:)fileMover(isPresented:file:onCompletion:onCancellation:)fileMover(isPresented:files:onCompletion:onCancellation:)
Configuring a file dialog
fileDialogBrowserOptions(_:)fileDialogConfirmationLabel(_:)fileDialogCustomizationID(_:)fileDialogDefaultDirectory(_:)fileDialogImportsUnresolvedAliases(_:)fileDialogMessage(_:)fileDialogURLEnabled(_:)FileDialogBrowserOptions