How it works
ContentToolbarPlacement is a structure that identifies a region of the toolbar associated with a view's content, as distinct from the navigation bar or other system-managed areas. You use it with toolbar modifiers to scope changes — such as showing, hiding, or removing toolbar elements — to the content-bearing portion of a container like a List inside a NavigationStack. Reach for it when you need to address the content toolbar specifically rather than the whole toolbar surface, for example to suppress an automatically supplied title.
Identify the structure and its role
ContentToolbarPlacementnames the content area of a toolbar so that toolbar APIs can target it. It conforms to the placement protocols SwiftUI uses to route toolbar items and configuration, letting you speak about "the content toolbar" rather than an unscoped toolbar. In the example it underlies the placement that the.toolbar(removing:)modifier operates against for theListcontent.Attach it through a toolbar modifier
You apply a
ContentToolbarPlacementindirectly by passing a default toolbar element to a toolbar modifier on a content view. Here.toolbar(removing: .title)is attached to theList, telling SwiftUI to act on that view's content toolbar instead of leaving its default decorations in place.Choose the element to affect with
.titleThe
.titlevalue designates the default title element that the content toolbar provides. Combined with the placement, it pinpoints exactly what changes — in this case the navigation title contributed by.navigationTitle("Mail")— so the removal is precise rather than wholesale.Anchor it inside a navigation container
Content toolbar placement is meaningful only where a container supplies a toolbar, so the affected view lives inside a
NavigationStack. TheListofText("Inbox"),Text("Sent"), andText("Drafts")is the content whose toolbar the placement refers to; the surrounding stack is simply where the symbol plugs in.
.toolbar(removing: .title) line and the title "Mail" reappears, showing that the modifier was acting on the content toolbar's .title element.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 ContentToolbarPlacementDemo: View {
var body: some View {
NavigationStack {
List {
Text("Inbox")
Text("Sent")
Text("Drafts")
}
.navigationTitle("Mail")
.toolbar(removing: .title)
}
}
}