iPhone SwiftUI layouts
Explore SwiftUI APIs, components, and modifiers with interactive iPhone previews, Swift code, and Apple documentation. Compare every available orientation, appearance, and design.
201elements
Alert
Message Item Alert
Presents an alert with a message using the given data to produce the alert’s content and a localized string key for a title.
Explore Message Item Alert on iPhone in portrait, with SwiftUI code and Apple API documentation.
SwiftUI code
struct Item {
let message: String
}
@State var item: Item? = .init(message: "Foo")
var body: some View {
Text("Foo")
.alert("Title", item: $item) { alertItem in
Button("Ok") {
print("Item nilled")
}
} message: { alertItem in
Text(alertItem.message)
}
}Compatibility
iOS 27.0+ iPadOS 27.0+ macOS 27.0+ watchOS 27.0+ tvOS 27.0+ visionOS 27.0+
Tags
Found an issue or have a suggestion?
All variants
Every available iPhone screenshot for Message Item Alert.