Skip to content

Duration and Placement

B.Cem edited this page Sep 3, 2026 · 2 revisions

Duration and Placement

Duration

dismissDelay takes a PeekDialogDelay:

Case Behavior
.short Auto-dismiss after 2 seconds
.medium Auto-dismiss after 5 seconds
.long Auto-dismiss after 8 seconds
.custom(seconds:) Auto-dismiss after a custom interval
.persistent Stays until dismissed manually or by the binding
.peekDialog(with: $myItem, dismissDelay: .custom(seconds: 1.25)) { item in
    /* ... */
}

For the single-dialog isPresented: and with: modifiers the default is .persistent, so if you omit dismissDelay the dialog stays until you dismiss it. The stacked items: modifier defaults to .short.

Placement

placement positions the dialog vertically. It accepts a VerticalAlignment:

Value Position
.top (default) Top of the screen
.center Vertically centered
.bottom Bottom of the screen
.peekDialog(isPresented: $showDialog, dismissDelay: .medium, placement: .bottom) {
    /* ... */
}

The host already applies a small fixed edge padding (8 pt) for .top / .bottom.

Placement inset

Use .peekPlacementInset(_:) on the content inside the closure to add extra distance from the placement edge, on top of that fixed padding.

  • .top / .center — moves the dialog down
  • .bottom — moves the dialog up

It is applied as a visual offset (not layout padding), so it does not change the dialog’s layout size.

.peekDialog(isPresented: $showDialog, dismissDelay: .short, placement: .bottom) {
    Text("Copied to clipboard")
        .padding()
        .dialogStyle(.plain)
        .peekPlacementInset(24)
}

Like .dialogStyle and .peekInteractiveDismissDisabled, this must sit inside the content closure — Common Mistakes.

Clone this wiki locally