One Logo Pool Ball
SwiftUI · IOS API REFERENCE

ContentUnavailableView

struct · iOS 17.0+ · SDK 27.1

nonisolated struct ContentUnavailableView<Label, Description, Actions> where Label : View, Description : View, Actions : View

An interface, consisting of a label and additional content, that you display when the content of your app is unavailable to users. It is recommended to use `ContentUnavailableView` in situations where a view's content cannot be displayed. That could be caused by a network error, a list without items, a search that returns no results etc. You create an `ContentUnavailableView` in its simplest form, by providing a label and some additional content such as a description or a call to action: ContentUnavailableView { Label("No Mail", systemImage: "tray.fill") } description: { Text("New mails you receive will appear here.") } The system provides default `ContentUnavailableView`s that you can use in specific situations. The example below illustrates the usage of the ``ContentUnavailableView/search`` view: struct ContentView: View { @ObservedObject private var viewModel = ContactsViewModel() var body: some View { NavigationStack { List { ForEach(viewModel.searchResults) { contact in NavigationLink { ContactsView(contact) } label: { Text(contact.name) } } } .navigationTitle("Contacts") .searchable(text: $viewModel.searchText) .overlay { if searchResults.isEmpty { ContentUnavailableView.search } } } } }

Members (0)

This type has no directly callable members in this snapshot. See the framework’s skipped declarations for unsupported APIs.

Skipped declarations

8 declarations were excluded from these bindings. Each reason comes from the generator or the iOS SDK compiler.

ContentUnavailableView.init(label:description:actions:)

callback cannot propagate synchronous failure

ContentUnavailableView.body

This protocol needs associated types that cannot yet cross the bridge.

ContentUnavailableView.init(_:image:description:)

The iOS SDK compiler rejected this binding: referencing initializer 'init(_:image:description:)' on 'ContentUnavailableView' requires the types 'AnyView' and 'Label<Text, Image>' be equivalent

ContentUnavailableView.init(_:image:description:)

The iOS SDK compiler rejected this binding: referencing initializer 'init(_:image:description:)' on 'ContentUnavailableView' requires the types 'AnyView' and 'Label<Text, Image>' be equivalent

ContentUnavailableView.init(_:systemImage:description:)

The iOS SDK compiler rejected this binding: referencing initializer 'init(_:systemImage:description:)' on 'ContentUnavailableView' requires the types 'AnyView' and 'Label<Text, Image>' be equivalent

ContentUnavailableView.init(_:systemImage:description:)

The iOS SDK compiler rejected this binding: referencing initializer 'init(_:systemImage:description:)' on 'ContentUnavailableView' requires the types 'AnyView' and 'Label<Text, Image>' be equivalent

ContentUnavailableView.init(_:image:description:)

The iOS SDK compiler rejected this binding: referencing initializer 'init(_:image:description:)' on 'ContentUnavailableView' requires the types 'AnyView' and 'Label<Text, Image>' be equivalent

ContentUnavailableView.init(_:systemImage:description:)

The iOS SDK compiler rejected this binding: referencing initializer 'init(_:systemImage:description:)' on 'ContentUnavailableView' requires the types 'AnyView' and 'Label<Text, Image>' be equivalent

All SwiftUI types →