Add a Close button to SwiftUI modals on iOS 26
In iOS 26, SwiftUI introduces a new close button role designed for buttons that dismiss informational views or modals, for example, sheets showing read-only content or contextual details.
Unlike the existing cancel
role, which indicates discarding edits or abandoning progress, the close
role doesn't imply data loss. It doesn't perform any automatic dismissal by itself but provides internal semantics that help SwiftUI and the system understand the intent of the button, such as for accessibility and platform-consistent presentation.
Here's how we might use it in a modal sheet:
struct BirdDescriptionSheet: View {
@Environment(\.dismiss) private var dismiss
var body: some View {
NavigationStack {
BirdDescription()
.toolbar {
Button(role: .close) {
dismiss()
}
}
}
}
}
This adds a system-standard close button with an xmark
symbol without the need to define a custom label or icon.


It's a small but useful addition for aligning SwiftUI modals with platform conventions.