Interactive previews iPhone

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.

Message Item Alert - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview

Platform Compatibility

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

Tags

SwiftUI Code

Docs
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)
        }
}

Found an issue or have a suggestion?

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

More Alert Components

View all
Message Error Alert - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview
modifier

Message Error Alert

Presents an alert with a message when an error is present.

Item Alert - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview
modifier

Item Alert

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

Error Alert - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview
modifier

Error Alert

Presents an alert when an error is present.

Explore Other Components

Browse all
Overlay Arrangement Edge - iOS on iPhone Duo - Landscape - Partially Open - Liquid Glass - Light Mode - Preview
modifier

Overlay Arrangement Edge

The horizontal edge a view in an overlay arrangement occupies when the arrangement transitions to a horizontal layout. In this case, the primary view overlays the secondary view at the trailing edge when the screen is partially open in landscape.

Hide Sidebar Toggle - iOS on iPhone Duo - Landscape - Fully Open - Liquid Glass - Light Mode - Preview
modifier

Hide Sidebar Toggle

Removes the sidebar toggle toolbar item a NavigationSplitView adds by default.

Hinge State - iOS on iPhone Duo - Landscape - Fully Open - Liquid Glass - Light Mode - Preview
structure

Hinge State

A type encapsulating the state of a single hinge.

TextFieldLink - iOS on iPhone - Portrait - Flat Design - Light Mode - Preview
initializer

TextFieldLink

A control that requests text input from the user when pressed

Standard Colors - iOS on iPhone - Portrait - Flat Design - Light Mode - Preview
type

Standard Colors

The SwiftUI standard colors

Color Variants - iOS on iPhone - Portrait - Flat Design - Light Mode - Preview
modifier

Color Variants

HierarchicalShapeStyle, a shape style that maps to one of the numbered content styles

NavigationControlGroupStyle - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview
style

NavigationControlGroupStyle

The navigation control group style

VisionOS background materials - visionOS - Liquid Glass - Light Mode - Preview
type

VisionOS background materials

All background materials on visionOS