How it works
SearchUnavailableContent is the structure that represents the body of a static placeholder search view — the system's standard "no results" presentation, with its magnifying-glass icon, title, and message. You don't construct it yourself; SwiftUI builds it for you when you reach for ContentUnavailableView.search (or its search(text:) variant), and this type is what fills in the view's Label, Description, and Actions. Its job is to give the empty-search moment the same look and copy people see across the OS, so a query that returns nothing renders a consistent, platform-native state instead of a blank screen. Reach for it indirectly, through ContentUnavailableView.search, wherever a searchable list or grid can come back empty.
Get the content through ContentUnavailableView.search
You never name
SearchUnavailableContentat a call site or call an initializer on it. Instead, the search preset onContentUnavailableViewproduces it: the example writesContentUnavailableView.search(text: "swift ui"), and that static member returns aContentUnavailableViewwhose three generic arguments areSearchUnavailableContent.Label,SearchUnavailableContent.Description, andSearchUnavailableContent.Actions.Pass the query with the text parameter
The
search(text:)form takes the current query string so the placeholder can fold it into its description — phrasing the message around what the person actually typed. Heretext: "swift ui"is the valueSearchUnavailableContent.Descriptionrenders against; in a real app you'd hand it the binding driving.searchable, such as the live search text, so the copy stays in sync with the field.Prefer the bare search property inside a searchable hierarchy
There is also a parameterless
ContentUnavailableView.searchproperty. When the view sits within a.searchablehierarchy, SwiftUI parses the active query intoSearchUnavailableContent.Descriptionautomatically, so you don't supply the text yourself. Usesearch(text:), as the example does, only when you manage the query string outside the standard search environment.Rely on the nested Label, Description, and Actions views
SearchUnavailableContentexposes threeView-conforming members —SearchUnavailableContent.Label,SearchUnavailableContent.Description, andSearchUnavailableContent.Actions— that compose the icon-and-title, the explanatory line, and any call-to-action area. You don't instantiate these; they're created and laid out for you so the empty-search state matches the system presentation without writing your ownImage,Text, orButton.Treat the result as an ordinary view
Because the value returned by
search(text:)is aContentUnavailableViewbuilt fromSearchUnavailableContent, it conforms toViewand joins the normal modifier chain. In the example a single.padding()insets the whole placeholder; you'd typically drop it into an.overlaythat appears only when your filtered results are empty.
ContentUnavailableView.search(text: "swift ui") to the bare ContentUnavailableView.search to see how SearchUnavailableContent renders its description when no query string is supplied versus when one is.Example & preview
Press Run live & edit to compile it in your browser — then edit the Swift on the left and the preview re-renders live.
struct SearchUnavailableContentDemo: View {
var body: some View {
ContentUnavailableView.search(text: "swift ui")
.padding()
}
}