Interactive previews iPhone

Error Alert

Presents an alert when an error is present.

Error 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
enum FooError: LocalizedError {
    case bar

    var errorDescription: String? {
        switch self {
            case .bar:
            return "Bar error occurred."
        }
    }
}

@State private var error: FooError? = .bar

var body: some View {
    Text("Foo")
        .alert(error: $error) {
            Button("OK") {
                print("Error nilled")
            }
        }
}

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.

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

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.

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.

Explore Other Components

Browse all
Single Subscription Store View - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview
initializer

Single Subscription Store View

Creates a view that loads subscriptions based on a collection of product identifiers, and merchandises them with automatic marketing content.

Swipe Action - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview
modifier

Swipe Action

Adds custom swipe actions to a row in a list or container, notifying you when the actions are revealed or dismissed.

Default Adaptable Tab Bar Placement - iPadOS - Landscape - Liquid Glass - Light Mode - Preview
modifier

Default Adaptable Tab Bar Placement

Specifies the default placement for the tabs in a tab view using the adaptable sidebar style.

Navigation Container Background - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview
modifier

Navigation Container Background

Sets the container background of the enclosing container using a view.

Music Picker - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview
modifier

Music Picker

Presents a music picker to select items from the Apple Music catalog and the user’s music library.

Tab View Customization Behavior - iPadOS - Landscape - Liquid Glass - Light Mode - Preview
modifier

Tab View Customization Behavior

Configures the customization behavior of customizable tab view content.

NavigationSplitView - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview
initializer

NavigationSplitView

Creates a two-column navigation split view.

Link - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview
initializer

Link

A control for navigating to a URL