TechnologiesSwiftUI

DefaultToolbarItem struct

iOSmacOStvOSwatchOSvisionOSiOS 26.0+✓ renders

A toolbar item that represents a system component.

How it works

DefaultToolbarItem lets you place one of SwiftUI's system-provided toolbar controls into a toolbar by referring to it by kind, rather than building the control yourself. Some standard affordances — most notably search — are normally positioned and managed by the framework, and a DefaultToolbarItem gives you a handle to that built-in item so you can decide where it appears. Reach for it inside a toolbar builder when you want to relocate or explicitly position a system item, such as moving the search field down to the bottom bar.

  1. Add it inside a toolbar builder

    DefaultToolbarItem is a ToolbarContent value, so you list it in the closure passed to the .toolbar modifier just like a ToolbarItem. In the example it sits alongside the List within a NavigationStack, declared as the sole entry of .toolbar { DefaultToolbarItem(...) }.

  2. Choose the system item with the kind parameter

    The kind parameter names which framework-provided item you're referring to. Here it's .search, which identifies the search field that the .searchable(text:) modifier contributes — DefaultToolbarItem doesn't create a new search field, it represents that existing one.

  3. Position it with the placement parameter

    The placement parameter takes a ToolbarItemPlacement and decides where the item is shown. The example passes .bottomBar, which pulls the search affordance out of its default location and pins it to the bottom toolbar.

  4. Pair it with the feature that supplies the item

    Because DefaultToolbarItem points at a system item rather than defining one, the corresponding feature must be present for it to resolve. The .search kind only has something to place because .searchable(text: .constant("")) is applied to the same List.

Try it — Change the placement: argument from .bottomBar to .topBarTrailing and watch the search field move from the bottom toolbar up beside the "Inbox" navigation title.

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.

DefaultToolbarItem.swift
struct DefaultToolbarItemDemo: View {
    var body: some View {
        NavigationStack {
            List {
                Text("Mail")
                Text("Calendar")
                Text("Notes")
            }
            .navigationTitle("Inbox")
            .searchable(text: .constant(""))
            .toolbar {
                DefaultToolbarItem(kind: .search, placement: .bottomBar)
            }
        }
    }
}
Live preview
Search Mail Calendar Notes 9:41 Inbox
Search Mail Calendar Notes 9:41 Inbox
swift → lexer → parser → sema → uiir → canvas Open in Studio ↗
What's new in SwiftUI 27 →