Modals and Safari

Present pages as sheets, full-screen flows, popovers, and in-app web content.

Modal navigation uses the same registered ViewModel and view forms as stack navigation:

await navigator.PresentAsync(
    new EditProfileViewModel(profile, navigator),
    ModalStyle.Sheet(Detent.Medium, Detent.Large));

The navigation stacks guide covers the matching push and pop forms.

Dismiss the top presentation with DismissAsync(). A modal page's ConfirmLeave callback also applies to swipe-to-dismiss sheets and tapping outside popovers.

Presentation styles

  • Automatic lets UIKit choose.
  • Sheet(...) creates an interactive page sheet.
  • FullScreen covers the screen and unloads the background presentation.
  • FormSheet is a centered card on iPad and a full sheet on iPhone.
  • CurrentContext stays inside the current presentation context.
  • OverFullScreen and OverCurrentContext keep the covered content loaded.
  • Popover(anchor) points at a SkeleKit view on large displays and adapts on compact displays.

Use PresentViewAsync to present a registered or existing view directly.

Sheet detents

Pass detents from smallest to largest. The sheet opens at the first:

ModalStyle.Sheet(
    Detent.Height(240),
    Detent.Fraction(0.7),
    Detent.Large)

Detent.Medium and Large use the system heights. Content follows the page's measured content and visible navigation chrome, updating when layout changes. Fixed heights are clamped to available space; fractions must be greater than zero and no greater than one.

In-app Safari

OpenUrlAsync uses SFSafariViewController for an HTTP or HTTPS address:

await navigator.OpenUrlAsync(
    "https://example.com/help",
    ModalStyle.Automatic,
    entersReaderIfAvailable: false,
    barCollapsingEnabled: true,
    dismissButtonStyle: SafariDismissButtonStyle.Close);

The extended overload controls presentation, Reader mode, collapsing browser bars, and whether the dismiss button reads Close, Done, or Cancel. Content-sized detents are treated as full height because Safari owns its internal content measurement.

Use the platform launcher directly for schemes or handoffs that do not belong in the in-app browser.

Use WebView instead when web content must remain embedded inside the page layout rather than appearing as a browser presentation.