Item Alert
Presents an alert using the given data to produce the alert’s content and a text view as a title.
Platform Compatibility
Tags
SwiftUI Code
struct Item {}
@State var item: Item? = .init()
var body: some View {
Text("Foo")
.alert("Title", item: $item) { alertItem in
Button("Ok") {
print("Item nilled")
}
}
}Found an issue or have a suggestion?
More Alert Components
View allExplore Other Components
Browse allNavigationLinkPickerStyle
A picker style represented by a navigation link that presents the options by pushing a List-style picker view.
Content Unavailable Search Text
A pre-built placeholder for empty search results with search text
TabsPickerStyle
A picker style that presents options as segmented tabs. On macOS, this style produces a segmented picker with a visual treatment that distinguishes tab navigation from value selection. On iOS, tvOS, and visionOS, the visual appearance matches that of the standard standard .segmented style. On all supported platforms, VoiceOver announces options as tabs.
ToolbarItem Shared Background Visibility
Controls the visibility of the glass background effect on items in the toolbar. In certain contexts, such as the navigation bar on iOS and the window toolbar on macOS, toolbar items will be given a glass background effect that is shared with other items in the same logical grouping