-
-
Notifications
You must be signed in to change notification settings - Fork 0
Duration and Placement
B.Cem edited this page Sep 3, 2026
·
2 revisions
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 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.
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.