How it works
TabBarPlacement describes where content attaches in relation to a tab bar, giving SwiftUI a vocabulary for positioning accessory and bar-adjacent views. You reach for it when a TabView needs supplementary chrome — a now-playing strip, a mini player, a contextual toolbar — that should ride with the tab bar rather than scroll inside a tab's content. Because the type captures placement rather than the view itself, SwiftUI can decide how that content sits relative to the bar and adapt it as the tab bar expands, collapses, or floats on platforms that use a Liquid Glass tab bar. Treat it as the placement token that bottom-bar modifiers consult, not as something you typically construct by hand.
Anchor placement to a TabView
TabBarPlacement only has meaning in the presence of a tab bar, so the placement is resolved against the bar that a TabView vends. In the example the bar is established by the
TabViewthat wraps theTab("Home", systemImage: "house")andTab("Search", systemImage: "magnifyingglass")entries; that bar is the surface the placement positions content against.Apply a bottom accessory with tabViewBottomAccessory
The modifier that puts TabBarPlacement to work is
tabViewBottomAccessory, which installs a view in the bottom-accessory placement just above the tab bar. SwiftUI uses the placement to keep that accessory pinned to the bar region instead of treating it as ordinary tab content, so it persists as you move between tabs.Provide the accessory content
The placement defines the slot; the closure you hand to
tabViewBottomAccessorydefines what fills it. Here theHStackholdingImage(systemName: "music.note"), theText("Now Playing")label, aSpacer, and theImage(systemName: "play.fill")control is the content laid into the bottom-accessory placement.Let placement drive adaptation
Because the accessory lives in a placement rather than a fixed frame, SwiftUI can resize, inset, or collapse it as the tab bar changes state. The
.padding(.horizontal)on theHStacktunes the content's own insets, while the surrounding placement governs how the whole strip tracks the bar across size and platform variations.
Image(systemName: "forward.fill") after the Image(systemName: "play.fill") inside the HStack — and watch how the bottom-accessory placement keeps both pinned to the tab bar.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 TabBarPlacementDemo: View {
var body: some View {
TabView {
Tab("Home", systemImage: "house") {
Text("Home")
.padding()
}
Tab("Search", systemImage: "magnifyingglass") {
Text("Search")
.padding()
}
}
.tabViewBottomAccessory {
HStack {
Image(systemName: "music.note")
Text("Now Playing")
Spacer()
Image(systemName: "play.fill")
}
.padding(.horizontal)
}
}
}