---
title: "Item Alert | Explore SwiftUI"
description: "Presents an alert using the given data to produce the alert’s content and a text view as a title"
canonical_url: "https://exploreswiftui.com/library/alert/item-alert"
meta:
  author: "Explore SwiftUI"
  "og:description": "Presents an alert using the given data to produce the alert’s content and a text view as a title"
  "og:image": "https://exploreswiftui.com/_og/d/c_Component%2Ctitle_Item%2BAlert%2Cdescription_Explore%2Bvisually%2Bwith%2Bcode%2Bexamples%2Ccategory_Alert%2Cprops_eyJwbGF0Zm9ybXMiOlsiaU9TIiwiaVBhZE9TIiwibWFjT1MiLCJ3YXRjaE9TIiwidHZPUyIsInZpc2lvbk9TIl19%2Cp_Ii9saWJyYXJ5L2FsZXJ0L2l0ZW0tYWxlcnQi%2Cs_X8ULBAOxcTEn98i-.png"
  "og:image:height": "630"
  "og:image:type": image/png
  "og:image:width": "1200"
  "og:title": "Item Alert | Explore SwiftUI"
  "twitter:description": "Presents an alert using the given data to produce the alert’s content and a text view as a title"
  "twitter:image": "https://exploreswiftui.com/_og/d/c_Component%2Ctitle_Item%2BAlert%2Cdescription_Explore%2Bvisually%2Bwith%2Bcode%2Bexamples%2Ccategory_Alert%2Cprops_eyJwbGF0Zm9ybXMiOlsiaU9TIiwiaVBhZE9TIiwibWFjT1MiLCJ3YXRjaE9TIiwidHZPUyIsInZpc2lvbk9TIl19%2Cp_Ii9saWJyYXJ5L2FsZXJ0L2l0ZW0tYWxlcnQi%2Cs_X8ULBAOxcTEn98i-.png"
  "twitter:title": "Item Alert | Explore SwiftUI"
---

> Index of every page on this site: [llms.txt](https://exploreswiftui.com/llms.txt)

**Interactive previews**[ iPhone](https://exploreswiftui.com/iphone?element=197)

# **Item Alert**

Presents an alert using the given data to produce the alert’s content and a text view as a title.

![Item Alert - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview](https://exploreswiftui.com/api/images/197/variants/365?v=1790073478842&r=2&w=800&q=80&f=webp)

### **Platform Compatibility**

iOS 27.0+ iPadOS 27.0+ macOS 27.0+ watchOS 27.0+ tvOS 27.0+ visionOS 27.0+

### **Tags**

### **SwiftUI Code**

[ Docs](<https://developer.apple.com/documentation/SwiftUI/View/alert(_:item:actions:)-8zxet>)

```
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?**

Created: June 9, 2026Updated: June 9, 2026

![Connect Wizard](https://exploreswiftui.com/_ipx/f_webp&q_80&s_48x48/images/connect-wizard-icon.png)

**Connect Wizard**

**Unlock insights App Store Connect doesn’t show you.**

[** Get Started **](https://apps.apple.com/app/apple-store/id6747314580?pt=121213751&ct=Explore%20SwiftUI%20Banner&mt=8)

```json
{"@context":"https://schema.org","@graph":[{"@id":"https://exploreswiftui.com/#website","@type":"WebSite","description":"A visual library for SwiftUI APIs, components, and modifiers","inLanguage":"en-US","name":"Explore SwiftUI","url":"https://exploreswiftui.com/","publisher":{"@id":"https://exploreswiftui.com/#identity"}},{"@id":"https://exploreswiftui.com/library/alert/item-alert#webpage","@type":"WebPage","dateModified":"2026-06-09T18:59:10.132Z","datePublished":"2026-06-09T18:59:10.132Z","description":"Presents an alert using the given data to produce the alert’s content and a text view as a title","name":"Item Alert","url":"https://exploreswiftui.com/library/alert/item-alert","breadcrumb":{"@id":"https://exploreswiftui.com/library/alert/item-alert#breadcrumb"},"isPartOf":{"@id":"https://exploreswiftui.com/#website"},"potentialAction":[{"@type":"ReadAction","target":["https://exploreswiftui.com/library/alert/item-alert"]}],"primaryImageOfPage":{"@id":"https://exploreswiftui.com/#logo"}},{"@id":"https://exploreswiftui.com/#identity","@type":"Organization","description":"A visual library for SwiftUI APIs, components, and modifiers","name":"Explore SwiftUI","url":"https://exploreswiftui.com","logo":{"@id":"https://exploreswiftui.com/#logo"},"sameAs":["https://x.com/Typ0genius","https://mastodon.social/@Typ0genius"]},{"@id":"https://exploreswiftui.com/library/alert/item-alert#article","dateModified":"2026-06-09T18:59:10.132Z","datePublished":"2026-06-09T18:59:10.132Z","description":"Presents an alert using the given data to produce the alert’s content and a text view as a title","headline":"Item Alert","inLanguage":"en-US","name":"Item Alert","thumbnailUrl":"https://exploreswiftui.com/api/images/197/variants/365?v=1790073478842&r=2","url":"https://exploreswiftui.com/library/alert/item-alert","@type":["Article","TechArticle"],"about":{"@type":"Thing","name":"SwiftUI"},"author":{"@id":"https://exploreswiftui.com/#identity"},"image":{"@id":"https://exploreswiftui.com/#/schema/image/1"},"isPartOf":{"@type":"WebSite","name":"Explore SwiftUI","url":"https://exploreswiftui.com"},"mainEntityOfPage":{"@id":"https://exploreswiftui.com/library/alert/item-alert#webpage"},"publisher":{"@id":"https://exploreswiftui.com/#identity"}},{"@id":"https://exploreswiftui.com/library/alert/item-alert#/schema/software-source-code/1","@type":"SoftwareSourceCode","codeRepository":"https://developer.apple.com/documentation/SwiftUI/View/alert(_:item:actions:)-8zxet","codeSampleType":"full example","description":"Presents an alert using the given data to produce the alert’s content and a text view as a title","name":"Item Alert SwiftUI Example","programmingLanguage":"Swift","runtimePlatform":"SwiftUI","text":"struct Item {}\n\n@State var item: Item? = .init()\n\nvar body: some View {\n    Text(\"Foo\")\n        .alert(\"Title\", item: $item) { alertItem in\n            Button(\"Ok\") {\n                print(\"Item nilled\")\n            }\n        }\n}","about":[{"@type":"Thing","name":"SwiftUI"},{"@type":"Thing","name":"Alert"},{"@type":"Thing","name":"Item Alert"}]},{"@id":"https://exploreswiftui.com/library/alert/item-alert#breadcrumb","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","name":"Home","item":"https://exploreswiftui.com","position":1},{"@type":"ListItem","name":"Alert","item":"https://exploreswiftui.com/library/alert","position":2},{"@type":"ListItem","name":"Item Alert","item":"https://exploreswiftui.com/library/alert/item-alert","position":3}]},{"@id":"https://exploreswiftui.com/#logo","@type":"ImageObject","caption":"Explore SwiftUI","contentUrl":"https://exploreswiftui.com/apple-touch-icon.png","inLanguage":"en","url":"https://exploreswiftui.com/apple-touch-icon.png"},{"@id":"https://exploreswiftui.com/#/schema/image/1","@type":"ImageObject","contentUrl":"https://exploreswiftui.com/api/images/197/variants/365?v=1790073478842&r=2","inLanguage":"en","url":"https://exploreswiftui.com/api/images/197/variants/365?v=1790073478842&r=2"}]}
```